swagger-maven-plugin
swagger-maven-plugin copied to clipboard
Performance issue - JaxrsReader.scanClasspathForTags() will not complete until all classes in classpath are parsed
(Sample project is attached. Please run run.bat script to see the issue) demo.zip
My project containing a JAR file which has an incorrect Class-Path entry (which is pointing to "/"). As a result, when I building using this plugin, the plugin will never stop because JaxrsReader.scanClasspathForTags() will try to scan whole drive for classes.
Below is the stack trace when debugging the issue:
....
Reflections.scan(URL) line: 236
Reflections.scan() line: 203
Reflections.<init>(Configuration) line: 128
Reflections.<init>(Object...) line: 169
Reflections.<init>(String, Scanner...) line: 142
JaxrsReader.scanClasspathForTags() line: 201
In the source code, I found the call to new Reflections("") will never stop because of the bad entry in the classpath
private Map<String, Tag> scanClasspathForTags() {
Map<String, Tag> tags = new HashMap<String, Tag>();
for (Class<?> aClass: new Reflections("").getTypesAnnotatedWith(SwaggerDefinition.class)) {
Can you improve the logic to avoid scanning the whole classpath? Even if there is no bad entry in classpath, this logic still has bad performance.
Thanks.
Hey @tha2015, @Postremus did you make any progress with this issue? I have the same problem. Tnx
I just excluded the jar with bad Class-Path entry to avoid the issue. The prolem is to find which jars are causing issue
Thank you for the reply! @tha2015 for the future reference, I solved it by adding param: <swaggerApiReader>com.github.kongchen.swagger.docgen.reader.SwaggerReader</swaggerApiReader> Which sets reader to the SwaggerReader ( the reader that build swagger.json on runtime). It solved the issue.