Invoke this method to transition the service to the State#FAILED. The service will not be stopped if it is running. Invoke this method when a service has failed critically or otherwise cannot be started nor stopped.
(Throwable cause)
| 401 | |
| 402 | |
| 403 | protected final void notifyFailed(Throwable cause) { |
| 404 | checkNotNull(cause); |
| 405 | monitor.enter(); |
| 406 | try { |
| 407 | State previous = state(); |
| 408 | switch (previous) { |
| 409 | case NEW: |
| 410 | case TERMINATED: |
| 411 | throw new IllegalStateException("Failed while in state:" + previous, cause); |
| 412 | case RUNNING: |
| 413 | case STARTING: |
| 414 | case STOPPING: |
| 415 | snapshot = new StateSnapshot(FAILED, false, cause); |
| 416 | failed(previous, cause); |
| 417 | break; |
| 418 | case FAILED: |
| 419 | // Do nothing |
| 420 | break; |
| 421 | default: |
| 422 | throw new AssertionError("Unexpected state: " + previous); |
| 423 | } |
| 424 | } finally { |
| 425 | monitor.leave(); |
| 426 | executeListeners(); |
| 427 | } |
| 428 | } |
| 429 | |
| 430 | @Override |
| 431 | public final boolean isRunning() { |
no test coverage detected