Uploaded image for project: 'Red Hat Fuse'
  1. Red Hat Fuse
  2. ENTESB-6607

camel-jetty: IllegalStateException when a handler is added

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • jboss-fuse-6.2-patches
    • jboss-fuse-6.2.1
    • Camel
    • None
    • % %

      It seems that the behaviour of JettyHttpComponent.connect() in the Red Hat build of Camel 2.15.1 in 6.2.1 R3 and later is out of line with the corresponding upstream version, and changed for unclear reasons between 6.2.1 R2 and 6.2.1 R3. In 6.2.1 R2 (and in all the upstream branches I had time to check) we have , around line 341 of JettyHttpComponent.java:

       if (endpoint.getHandlers() != null && !endpoint.getHandlers().isEmpty()) {
                          // As the server is started, we need to stop the server for a while to add the new handler
                          connectorRef.server.stop();
                          addJettyHandlers(connectorRef.server, endpoint.getHandlers());
                          connectorRef.server.start();
                      }
      

      But the Red Hat build has

       if (endpoint.getHandlers() != null && !endpoint.getHandlers().isEmpty()) {
                          // As the server is started, we need to stop the server for a while to add the new handler
                          addJettyHandlers(connectorRef.server, endpoint.getHandlers());
                      }
      

      it's odd that the comment has been retained, and is now meaningless.

      This problem seems to be the cause of exceptions like this when adding handlers programatically. These problems were not apparent in 6.2.1 R2.

      java.lang.IllegalStateException: STARTED
      at org.eclipse.jetty.server.handler.HandlerWrapper.setServer(HandlerWrapper.java:130)
      at org.eclipse.jetty.server.handler.HandlerWrapper.setHandler(HandlerWrapper.java:81)
      at org.apache.camel.component.jetty.JettyHttpComponent.addJettyHandlers(JettyHttpComponent.java:1004)
      at org.apache.camel.component.jetty.JettyHttpComponent.connect(JettyHttpComponent.java:347)
      at org.apache.camel.component.http.HttpEndpoint.connect(HttpEndpoint.java:183)
      at org.apache.camel.component.http.HttpConsumer.doStart(HttpConsumer.java:53)
      at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
      

            pantinor@redhat.com Paolo Antinori
            rhn-support-kboone Kevin Boone
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: