[BUG] Use of GlobalSettings in gradle-plugin leads to race conditions in Gradle 6.6+
Created by: nhoughto
Description
On the latest version of Gradle 6.6 and latest generator 4.3.1 I am seeing inconsistent generation of outputs, some projects where model generation is disabled, intermittently models appear and the next run they do not appear. I believe this is due to running my multi-module gradle project with a number of openapi generator tasks running at once, the current problem is with ~5 concurrent generations running.
It appears that there is a race condition in the GeneratorTask and the use of a global singleton GlobalSettings:
GlobalSettings appears to defend against this via a ThreadLocal map which seems to work in Gradle 6.5, but fail in Gradle 6.6+. I'm not sure whats changed in Gradle land but it seems like any settings configured via GlobalSettings conflict/collide with each other when running concurrently, if I set --max-workers 1
everything works as expected, if workers is > 1 then the problems start.
openapi-generator version
4.3.1
OpenAPI declaration file content or url
n/a
Generation Details
n/a
Steps to reproduce
n/a
Related issues/PRs
None that I can see
Suggest a fix
Not sure, it seems like something in upstream Gradle has changed in the 6.5 -> 6.6 upgrade, I was able to work around it by moving from configuration that ended up in GlobalSettings and re-implemented it in ignore files.