Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #1597
Closed
Open
Issue created Dec 03, 2018 by Administrator@rootContributor

Bug (Race-Condition) - Refactor use of System.(get|set|clear)Property

Created by: gndrm

Description

When using the openapi-generator-maven-plugin in a multi module Build with maven failsafe-plugin for Integration Tests, the generator is not working properly. Race conditions arise, since surefires AbstractSurefireMojo (Base class for IntegrationTestMojo) clones the Properties Object returned by System.getProperties() before the run and sets it as the new Properties in System afterwards.

Now consider the following sequence of statements:

  1. surefire clones System properties
  2. generator-maven-plugin sets Properties
  3. surefire resets System Properties (generators properties are gone)
  4. DefaultGenerator tries to read Properties

This breaks the plugin configuration and causes unintended behaviour.

openapi-generator version

3.3.0, but as far as i can see, the newest version doesn't change anything in regard to this behaviour.

Suggest a fix/enhancement

remove all references to System Properties, since those can be modified from everywhere and everybody inside the same JVM. Instead define a POJO-GeneratorProperties Object, which gets passed from GodeGenMojo to DefaultGenerator. Alternatively (what i have done so far) implement static class which initially clones the System Properties in a InheritableThreadLocal field and provides access to the cloned Object via (get|set|clear)Property Methods. This way you still have easy access to manipulate those properties, but you are not running the risk of losing Properties in a multi-threaded environment. This would also guarantee right behaviour, if you want to run two parallel executions of generator-plugin.

Assignee
Assign to
Time tracking