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

doStop() is called on Services which haven't been started when route autoStart=false

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Won't Fix
    • 2.9.0
    • 2.10.0
    • camel-core
    • None
    • Patch Available
    • Unknown

    Description

      While unit testing the new camel-mongodb component, I realised that my consumer's doStop() method is called even if the route had autoStart=false and was never started.

      This occurs because when autoStartup=false, and the route has never been started manually, the RouteService's state flags are all false.

      During the cascading stopping routine, the ServiceHelper.isStopped() method is used to determine whether a service should be stopped or not. Since this method only checks the stopped and stopping flags, it returns false which indicates to the caller that the service is either started or suspended.

      The stop routine will then proceed to call doStop on the service, which is erroneous.

      To fix this, I propose to add the following new logic to the ServiceHelper.isStopped() method:

                  // if none of the flags is true, consider that the service is uninitialized, equating this status to stopped
                  if (!(service.isStarted() || service.isStarting() || 
                          service.isStopped() || service.isStopping() || 
                          service.isSuspended() || service.isSuspending())) 
                  {
                      return true;
                  }
      

      Attachments

        Activity

          People

            raulvk Raúl Kripalani
            raulvk Raúl Kripalani
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: