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)
| 399 | |
| 400 | |
| 401 | protected final void notifyFailed(Throwable cause) { |
| 402 | checkNotNull(cause); |
| 403 | monitor.enter(); |
| 404 | try { |
| 405 | State previous = state(); |
| 406 | switch (previous) { |
| 407 | case NEW: |
| 408 | case TERMINATED: |
| 409 | throw new IllegalStateException("Failed while in state:" + previous, cause); |
| 410 | case RUNNING: |
| 411 | case STARTING: |
| 412 | case STOPPING: |
| 413 | snapshot = new StateSnapshot(FAILED, false, cause); |
| 414 | failed(previous, cause); |
| 415 | break; |
| 416 | case FAILED: |
| 417 | // Do nothing |
| 418 | break; |
| 419 | default: |
| 420 | throw new AssertionError("Unexpected state: " + previous); |
| 421 | } |
| 422 | } finally { |
| 423 | monitor.leave(); |
| 424 | executeListeners(); |
| 425 | } |
| 426 | } |
| 427 | |
| 428 | @Override |
| 429 | public final boolean isRunning() { |
no test coverage detected