protected final void notifyFailed(Throwable cause) {
    checkNotNull(cause);

    monitor.enter();
    try {
      State previous = state();
      switch (previous) {
        case NEW:
        case TERMINATED:
          throw new IllegalStateException("Failed while in state:" + previous, cause);
        case RUNNING:
        case STARTING:
        case STOPPING:
          snapshot = new StateSnapshot(FAILED, false, cause);
          failed(previous, cause);
          break;
        case FAILED:
          // Do nothing
          break;
        default:
          throw new AssertionError("Unexpected state: " + previous);
      }
    } finally {
      monitor.leave();
      executeListeners();
    }
  }
protected final void notifyFailed ( Throwable cause ) { checkNotNull ( cause ) ; monitor . enter ( ) ; try { State previous = state ( ) ; switch ( previous ) { case NEW : case TERMINATED : throw new IllegalStateException ( "Failed while in state:" + previous , cause ) ; case RUNNING : case STARTING : case STOPPING : snapshot = new StateSnapshot ( FAILED , false , cause ) ; failed ( previous , cause ) ; break ; case FAILED : break ; default : throw new AssertionError ( "Unexpected state: " + previous ) ; } } finally { monitor . leave ( ) ; executeListeners ( ) ; } }
Invoke this method to transition the service to the {@link State#FAILED}. The service will
<b>not be stopped</b> if it is running. Invoke this method when a service has failed critically
or otherwise cannot be started nor stopped.