Skip to content

Commit

Permalink
Fix exception message in lifecycle
Browse files Browse the repository at this point in the history
This commit fixes the exception messages for lifecycles when stopping in
illegal states.

Relates elastic#18189
  • Loading branch information
jasontedor committed May 6, 2016
1 parent 9988105 commit d0d2d2b
Showing 1 changed file with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

package org.elasticsearch.common.component;


/**
* Lifecycle state. Allows the following transitions:
* <ul>
Expand Down Expand Up @@ -56,7 +55,7 @@
*/
public class Lifecycle {

public static enum State {
public enum State {
INITIALIZED,
STOPPED,
STARTED,
Expand Down Expand Up @@ -141,9 +140,9 @@ public boolean canMoveToStopped() throws IllegalStateException {
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 {
Expand All @@ -156,9 +155,9 @@ public boolean moveToStopped() throws IllegalStateException {
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 {
Expand All @@ -172,7 +171,6 @@ public boolean canMoveToClosed() throws IllegalStateException {
return true;
}


public boolean moveToClosed() throws IllegalStateException {
State localState = state;
if (localState == State.CLOSED) {
Expand All @@ -189,4 +187,5 @@ public boolean moveToClosed() throws IllegalStateException {
public String toString() {
return state.toString();
}

}

0 comments on commit d0d2d2b

Please sign in to comment.