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

DefaultCamelContext.isStarting returns incorrect status

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.6.0, 2.0-M1
    • 1.6.1, 2.0-M2
    • camel-core
    • None

    Description

      DefaultCamelContext.isStarting returns true while it actually not started.
      So the following groovy test case fails:

      test.groovy
      import org.apache.camel.impl.DefaultCamelContext;
      import org.apache.camel.language.groovy.GroovyRouteBuilder;
      
      class Foo {
          def name
          def data
          void run(data) {
              println "[${name}] got ${data}"
              this.data = data
          }
      }
      
      public class MyRoute extends GroovyRouteBuilder {
          def bean = new Foo(name: "bean")
          protected void configure() {
              from("direct:start").bean(bean, "run")
          }
      }
      
      camelCtx = new DefaultCamelContext()
      route = new MyRoute()
      camelCtx.addRoutes(route);
      
      Thread.start {
          camelCtx.start();
      }
      
      while (camelCtx.isStarting()) {
          Thread.sleep(1000)
      }
      
      camelCtx.createProducerTemplate().sendBody("direct:start", "data")
      if (!route.bean.data) {
          println "FAILED: no data has been received!"
      } else {
          println "PASSED"
      }
      
      camelCtx.stop();
      

      Note, after moving of

      camelCtx.addRoutes(route)
      

      after

      Thread.start {
          camelCtx.start();
      }
      

      the test passes.

      Also the program does not finish after camelCtx.stop();

      Attachments

        Activity

          People

            njiang Willem Jiang
            san Alexander Kleymenov
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: