kbuntrock / openapi-maven-plugin

Generate openapi documentation for SpringMVC or JaxRS/JakartaRS projects.
https://kbuntrock.github.io/openapi-maven-plugin/
MIT License
14 stars 11 forks source link

Concurrency bug #143

Open dantheperson opened 3 weeks ago

dantheperson commented 3 weeks ago

I have a build with 20+ maven modules where about a dozen contain rest controllers. If i run with mvn clean install all is good But we normally run the build in parallel for significant speed savings with mvn clean install -T1C

Then we hit this issue non-deterministically

if(referenceDataObject == null) {
// Investigation on a rare bug where the reference is not found.
throw new RuntimeException(
    "Writing schema but could not find a reference for class " + dataObject.getJavaClass().getSimpleName());
}

I suspect the issue is in ApiResourceScanner, where a static reference to the TagLibrary gets overwritten.

public TagLibrary scanRestControllers() throws MojoFailureException {

final TagLibrary library = new TagLibrary();
TagLibraryHolder.INSTANCE.setTagLibrary(library);
kbuntrock commented 3 weeks ago

Thank you @dantheperson, I think you are right. Fun fact: after almost 2 years of utilisation, someone in my company reported me this issue yesterday. 😮

This will require me a bit of work since it is not the only "not thread safe" logic.