Uploaded image for project: 'JBoss Enterprise Application Platform'
  1. JBoss Enterprise Application Platform
  2. JBEAP-19599

(7.3.z) Smallrye OpenAPI annotation scanner throws StackOverflowError when processing JAX-RS resource classes which implement a locator that will return the class itself

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 7.3.3.CR1, 7.3.3.GA
    • EAP-XP-1.0.0.GA-CR1, EAP-XP-1.0.0.GA-CR2
    • MP OpenAPI
    • None
    • +
    • 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(OpenApiAnnotationScanner.java:422)
      	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
      	at java.base/java.util.stream.ReferencePipeline.accept(ReferencePipeline.java:195)
      	at java.base/java.util.stream.ReferencePipeline.accept(ReferencePipeline.java:195)
      	at java.base/java.util.stream.ReferencePipeline.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
              fburzigo Fabio Burzigotti
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: