Uploaded image for project: 'WildFly'
  1. WildFly
  2. WFLY-13545

Smallrye OpenAPI annotaton scanner throws StackOverflowError when processing JAX-RS resource classes which implement a locator that will return the class itself

XMLWordPrintable

    • Hide

      A reproducer was isolated [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.

      [1]
      https://github.com/fabiobrz/microprofile-openapi-example/tree/subresource-locator-repro

      Show
      A reproducer was isolated [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. [1] https://github.com/fabiobrz/microprofile-openapi-example/tree/subresource-locator-repro

      When deploying a WAR which contains a JAX-RS resource class which is declaring a locator that is supposed to return the resource class itself - i.e. this - the depoyment fails with a StackOverflowError.
      The annotation scanner loops until the stack overflow happens because it tries to process the JAX-RS resource class recursively and maybe the process tself should be protected against this case.

      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)
      ...
      

      The failure was initially noticed during RESTEasy tests against EAP XP 1.0.0 CR1 and CR2.
      The SmallRye OpenAPI versions that I tested this against are 1.1.21 and 1.1.22.

            pferraro@redhat.com Paul Ferraro
            pferraro@redhat.com Paul Ferraro
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: