Jetty
  1. Jetty
  2. JETTY-1316

AbstractLifeCycle.isRunning() returns false if state changes from STARTING to STARTED during call

    Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 6.1.24
    • Fix Version/s: 6.1.27
    • Component/s: None
    • Labels:
      None
    • Environment:
      Any - but we discovered it on a Linux box
    • Number of attachments :
      0

      Description

      The current implementation of AbstractLifeCycle.isRunning() may return false if the state of the component changes from STARTING to STARTED during the call.

      This was discovered when the SelectChannelConnector.doStart() starts an acceptor thread - which fails to enter the accept loop due to isRunning() returning false. We narrowed it down to the main thread changing the state of the lifecycle immediately after spawning the thread - which causes the comparison checks in isRunning() to fail. (This happens one out of 300 attempts. Yes - it's rare but was happening enough to cause nightly integration tests to fail).

      We've worked around the issue by extending the SelectChannelConnector class and overriding the isRunning() method.

        Activity

        Hide
        Dave Messink added a comment -

        Someone suggested that I include my patch. I'd morph the AbstractLifeCycle.isRunning() method as follows:

        public boolean isRunning()

        { final int state = _state; return state == STARTING || state == STARTED; }
        Show
        Dave Messink added a comment - Someone suggested that I include my patch. I'd morph the AbstractLifeCycle.isRunning() method as follows: public boolean isRunning() { final int state = _state; return state == STARTING || state == STARTED; }
        Hide
        Michael Gorovoy added a comment -

        Thank you very much for reporting this issue. I've committed a minor variation of your patch. Marking this ticket as resolved.

        Committed r6594.

        Show
        Michael Gorovoy added a comment - Thank you very much for reporting this issue. I've committed a minor variation of your patch. Marking this ticket as resolved. Committed r6594.

          People

          • Assignee:
            Michael Gorovoy
            Reporter:
            Dave Messink
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: