Fix exception message in lifecycle

This commit fixes the exception messages for lifecycles when stopping in
illegal states.

Relates #18189
This commit is contained in:
Jason Tedor 2016-05-06 16:14:43 -04:00
parent 9988105114
commit d0d2d2be8c
1 changed files with 6 additions and 7 deletions

View File

@ -19,7 +19,6 @@
package org.elasticsearch.common.component;
/**
* Lifecycle state. Allows the following transitions:
* <ul>
@ -56,7 +55,7 @@ package org.elasticsearch.common.component;
*/
public class Lifecycle {
public static enum State {
public enum State {
INITIALIZED,
STOPPED,
STARTED,
@ -141,9 +140,9 @@ public class Lifecycle {
return false;
}
if (localState == State.CLOSED) {
throw new IllegalStateException("Can't move to started state when closed");
throw new IllegalStateException("Can't move to stopped state when closed");
}
throw new IllegalStateException("Can't move to started with unknown state");
throw new IllegalStateException("Can't move to stopped with unknown state");
}
public boolean moveToStopped() throws IllegalStateException {
@ -156,9 +155,9 @@ public class Lifecycle {
return false;
}
if (localState == State.CLOSED) {
throw new IllegalStateException("Can't move to started state when closed");
throw new IllegalStateException("Can't move to stopped state when closed");
}
throw new IllegalStateException("Can't move to started with unknown state");
throw new IllegalStateException("Can't move to stopped with unknown state");
}
public boolean canMoveToClosed() throws IllegalStateException {
@ -172,7 +171,6 @@ public class Lifecycle {
return true;
}
public boolean moveToClosed() throws IllegalStateException {
State localState = state;
if (localState == State.CLOSED) {
@ -189,4 +187,5 @@ public class Lifecycle {
public String toString() {
return state.toString();
}
}