()
| 221 | } |
| 222 | |
| 223 | @CanIgnoreReturnValue |
| 224 | @Override |
| 225 | public final Service stopAsync() { |
| 226 | if (monitor.enterIf(isStoppable)) { |
| 227 | try { |
| 228 | State previous = state(); |
| 229 | switch (previous) { |
| 230 | case NEW: |
| 231 | snapshot = new StateSnapshot(TERMINATED); |
| 232 | terminated(NEW); |
| 233 | break; |
| 234 | case STARTING: |
| 235 | snapshot = new StateSnapshot(STARTING, true, null); |
| 236 | stopping(STARTING); |
| 237 | break; |
| 238 | case RUNNING: |
| 239 | snapshot = new StateSnapshot(STOPPING); |
| 240 | stopping(RUNNING); |
| 241 | doStop(); |
| 242 | break; |
| 243 | case STOPPING: |
| 244 | case TERMINATED: |
| 245 | case FAILED: |
| 246 | // These cases are impossible due to the if statement above. |
| 247 | throw new AssertionError("isStoppable is incorrectly implemented, saw: " + previous); |
| 248 | default: |
| 249 | throw new AssertionError("Unexpected state: " + previous); |
| 250 | } |
| 251 | } catch (Throwable shutdownFailure) { |
| 252 | notifyFailed(shutdownFailure); |
| 253 | } finally { |
| 254 | monitor.leave(); |
| 255 | executeListeners(); |
| 256 | } |
| 257 | } |
| 258 | return this; |
| 259 | } |
| 260 | |
| 261 | @Override |
| 262 | public final void awaitRunning() { |
nothing calls this directly
no test coverage detected