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

NullPointerException while trying to get the Route Status on startup

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.18.2
    • Fix Version/s: 2.18.4, 2.19.1, 2.20.0
    • Component/s: camel-core
    • Labels:
      None
    • Environment:

      Spring Boot 1.5.1

    • Estimated Complexity:
      Novice

      Description

      Using a class that extends EventNotifierSupport, we advise a route by adding a processor in between two outputs.

      It looks like this

      from().processor().bean().processor().processor(advised),to().

      To add the adviceWith processor we listen to the routeAdded event and advice the route.

      While Camel is starting up there is a line (line number 2966) in the DefaultCamelContext that loops through the available routes for later logging the amount of routes started in the context. This calls for a method ( if(this.getRouteStatus(route.getId()).isStarted()) { ) that may return null if there are no routes running while this is being done, so IT WILL throw a NullPointerException.

      Since I'm advising routes while the context is being started, the route gets stopped and restarted, meanwhile the aforementioned method gets called and BUM.... NullPointerException.

      Here's the stacktrace:

      org.apache.camel.spring.boot.CamelSpringBootInitializationException: java.lang.NullPointerException
      at org.apache.camel.spring.boot.RoutesCollector.onApplicationEvent(RoutesCollector.java:124) ~[camel-spring-boot-2.18.2.jar:2.18.2]
      at org.apache.camel.spring.boot.RoutesCollector.onApplicationEvent(RoutesCollector.java:41) ~[camel-spring-boot-2.18.2.jar:2.18.2]
      at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:167) ~[spring-context-4.3.6.RELEASE.jar:4.3.6.RELEASE]
      at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) ~[spring-context-4.3.6.RELEASE.jar:4.3.6.RELEASE]
      at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:383) ~[spring-context-4.3.6.RELEASE.jar:4.3.6.RELEASE]
      at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:337) ~[spring-context-4.3.6.RELEASE.jar:4.3.6.RELEASE]
      at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:882) ~[spring-context-4.3.6.RELEASE.jar:4.3.6.RELEASE]
      at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:144) ~[spring-boot-1.5.1.RELEASE.jar:1.5.1.RELEASE]
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:545) ~[spring-context-4.3.6.RELEASE.jar:4.3.6.RELEASE]
      at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.1.RELEASE.jar:1.5.1.RELEASE]
      at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:737) [spring-boot-1.5.1.RELEASE.jar:1.5.1.RELEASE]
      at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:370) [spring-boot-1.5.1.RELEASE.jar:1.5.1.RELEASE]
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) [spring-boot-1.5.1.RELEASE.jar:1.5.1.RELEASE]
      at org.springframework.boot.SpringApplication$run.call(Unknown Source) [spring-boot-1.5.1.RELEASE.jar:1.5.1.RELEASE]
      at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) [groovy-all-2.4.7.jar:2.4.7]
      at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) [groovy-all-2.4.7.jar:2.4.7]
      at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125) [groovy-all-2.4.7.jar:2.4.7]
      at com.my.app.ApplicationMain.main(ApplicationMain.groovy:12) [main/:?]
      Caused by: java.lang.NullPointerException
      at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:2943) ~[camel-core-2.18.2.jar:2.18.2]
      at org.apache.camel.spring.boot.RoutesCollector.maybeStart(RoutesCollector.java:141) ~[camel-spring-boot-2.18.2.jar:2.18.2]
      at org.apache.camel.spring.boot.RoutesCollector.onApplicationEvent(RoutesCollector.java:116) ~[camel-spring-boot-2.18.2.jar:2.18.2]
      ... 17 more

        Attachments

          Activity

            People

            • Assignee:
              davsclaus Claus Ibsen
              Reporter:
              onimurasame Raul Astudillo Markoch
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: