smallrye-open-api: StackOverflow when implementing a resource locator which will return the resource class itself
Hi, I’ve noticed that some RESTEasy tests were failing against Wildfly because of some resource classes which have resource locators that are supposed to return the resource class itself - i.e. this.
Of course the annotation scanner goes crazy until the stack overflow happens because it tries to process the JAX-RS resource class recursively but I was wondering whether you think that this is an issue and that the annotation scanner should be protected against this case. WDYT?
The following stack trace represents the output of a deployment failure when an attempt to deploy a WAR with such a resource:
at org.jboss.logging@3.4.1.Final-redhat-00001//org.jboss.logging.Logger.getLogger(Logger.java:2490)
at io.smallrye.openapi//io.smallrye.openapi.runtime.scanner.dataobject.DataObjectDeque.<init>(DataObjectDeque.java:38)
at io.smallrye.openapi//io.smallrye.openapi.runtime.scanner.OpenApiDataObjectScanner.<init>(OpenApiDataObjectScanner.java:138)
at io.smallrye.openapi//io.smallrye.openapi.runtime.scanner.OpenApiDataObjectScanner.process(OpenApiDataObjectScanner.java:163)
at io.smallrye.openapi//io.smallrye.openapi.runtime.util.SchemaFactory.typeToSchema(SchemaFactory.java:360)
at io.smallrye.openapi//io.smallrye.openapi.runtime.scanner.OpenApiAnnotationScanner.createResponseFromJaxRsMethod(OpenApiAnnotationScanner.java:924)
at io.smallrye.openapi//io.smallrye.openapi.runtime.scanner.OpenApiAnnotationScanner.processJaxRsMethod(OpenApiAnnotationScanner.java:688)
at io.smallrye.openapi//io.smallrye.openapi.runtime.scanner.OpenApiAnnotationScanner.lambda$processJaxRsResourceClass$0(OpenApiAnnotationScanner.java:422)
at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
at java.base/java.util.HashMap$KeySpliterator.forEachRemaining(HashMap.java:1603)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
at io.smallrye.openapi//io.smallrye.openapi.runtime.scanner.OpenApiAnnotationScanner.processJaxRsResourceClass(OpenApiAnnotationScanner.java:420)
at io.smallrye.openapi//io.smallrye.openapi.runtime.scanner.OpenApiAnnotationScanner.processJaxRsSubResource(OpenApiAnnotationScanner.java:511)
at io.smallrye.openapi//io.smallrye.openapi.runtime.scanner.OpenApiAnnotationScanner.processJaxRsResourceClass(OpenApiAnnotationScanner.java:426)
at io.smallrye.openapi//io.smallrye.openapi.runtime.scanner.OpenApiAnnotationScanner.processJaxRsSubResource(OpenApiAnnotationScanner.java:511)
at io.smallrye.openapi//io.smallrye.openapi.runtime.scanner.OpenApiAnnotationScanner.processJaxRsResourceClass(OpenApiAnnotationScanner.java:426)
at io.smallrye.openapi//io.smallrye.openapi.runtime.scanner.OpenApiAnnotationScanner.processJaxRsSubResource(OpenApiAnnotationScanner.java:511)
...
I’ve isolated a reproducer [1] which has one method (FruitResource::getResourceLocator()) to demonstrate the failure.
The reproducer should fail by default. For a successful deploy the above mentioned method method should be commented.
The SmallRye OpenAPI versions that I tested this against are 1.1.21 and 1.1.22.
[1] https://github.com/fabiobrz/microprofile-openapi-example/tree/subresource-locator-repro
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 17 (17 by maintainers)
Hi @MikeEdgar, yeah I perfectly get your point. I’ve been taking care of RESTEasy TS failures which popped up since we started executing those tests against a Wildfly server instance with enabled MP OpenAPI subsystem. Looking at the list of the failing items I don’t have anything else at the moment.
Let’s hope I am not missing anything 😃
@fabiobrz - I agree, it makes sense for the scanner to guard against this scenario.