Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-12782

swagger-java - Provide more clear exception when model class is not visible to ClassResolver

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.18.5, 2.20.4, 2.21.2, 2.22.0
    • Fix Version/s: 2.22.2, 2.23.0
    • Component/s: camel-swagger
    • Labels:
      None
    • Environment:

      Apache Karaf

      Apache Camel (Rest DSL with Swagger)

    • Estimated Complexity:
      Unknown
    • Flags:
      Patch

      Description

      Within an OSGi the camel-swagger-java component be run within a different bundle than the routes and models required to generate the swagger document.  In this case the swagger code may not be able to read the model.  Currently this generates a Nullpointer Exception and the swagger document does not get rendered. 

      Would prefer that the exception be more specific to help developers with debugging.  Also toyed with the idea of converting to a LOG statement instead of an exception but it may be better to fail fast.

       

      org.apache.camel.camel-swagger-java - 2.22.0 | Error rendering Swagger API due null
      java.lang.NullPointerException: null
          at org.apache.camel.swagger.RestModelConverters.readClass(RestModelConverters.java:32) ~[108:org.apache.camel.camel-swagger-java:2.22.0]
          at org.apache.camel.swagger.RestSwaggerReader.appendModels(RestSwaggerReader.java:755) ~[108:org.apache.camel.camel-swagger-java:2.22.0]
          at org.apache.camel.swagger.RestSwaggerReader.parse(RestSwaggerReader.java:227) ~[108:org.apache.camel.camel-swagger-java:2.22.0]
          at org.apache.camel.swagger.RestSwaggerReader.read(RestSwaggerReader.java:113) ~[108:org.apache.camel.camel-swagger-java:2.22.0]
          at org.apache.camel.swagger.RestSwaggerSupport.renderResourceListing(RestSwaggerSupport.java:210) ~[108:org.apache.camel.camel-swagger-java:2.22.0]
          at org.apache.camel.swagger.RestSwaggerProcessor.process(RestSwaggerProcessor.java:119) [108:org.apache.camel.camel-swagger-java:2.22.0]
          at org.apache.camel.component.rest.RestApiProducer.process(RestApiProducer.java:36) [89:org.apache.camel.camel-core:2.22.0]
          at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61) [89:org.apache.camel.camel-core:2.22.0]
          at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:148) [89:org.apache.camel.camel-core:2.22.0]
          at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:181) [89:org.apache.camel.camel-core:2.22.0]
          at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:110) [89:org.apache.camel.camel-core:2.22.0]
          at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:548) [89:org.apache.camel.camel-core:2.22.0]
          at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201) [89:org.apache.camel.camel-core:2.22.0]
          at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201) [89:org.apache.camel.camel-core:2.22.0]
          at org.apache.camel.component.netty4.handlers.ServerChannelHandler.processAsynchronously(ServerChannelHandler.java:141) [105:org.apache.camel.camel-netty4:2.22.0]
          at org.apache.camel.component.netty4.handlers.ServerChannelHandler.channelRead0(ServerChannelHandler.java:112) [105:org.apache.camel.camel-netty4:2.22.0]
          at org.apache.camel.component.netty4.http.handlers.HttpServerChannelHandler.channelRead0(HttpServerChannelHandler.java:213) [106:org.apache.camel.camel-netty4-http:2.22.0]
          at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105) [55:io.netty.transport:4.1.25.Final]
          at org.apache.camel.component.netty4.http.handlers.HttpServerMultiplexChannelHandler.channelRead0(HttpServerMultiplexChannelHandler.java:113) [106:org.apache.camel.camel-netty4-http:2.22.0]
          at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105) [55:io.netty.transport:4.1.25.Final]
          at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [55:io.netty.transport:4.1.25.Final]
          at io.netty.channel.AbstractChannelHandlerContext.access$600(AbstractChannelHandlerContext.java:38) [55:io.netty.transport:4.1.25.Final]
          at io.netty.channel.AbstractChannelHandlerContext$7.run(AbstractChannelHandlerContext.java:353) [55:io.netty.transport:4.1.25.Final]
          at io.netty.util.concurrent.DefaultEventExecutor.run(DefaultEventExecutor.java:66) [51:io.netty.common:4.1.25.Final]
          at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:884) [51:io.netty.common:4.1.25.Final]
          at java.lang.Thread.run(Thread.java:748) [?:?]

        Attachments

          Activity

            People

            • Assignee:
              davsclaus Claus Ibsen
              Reporter:
              bobpaulin Bob Paulin
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: