Selaa lähdekoodia

Fix exception message in lifecycle

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

Relates #18189
Jason Tedor 9 vuotta sitten
vanhempi
commit
d0d2d2be8c

+ 6 - 7
core/src/main/java/org/elasticsearch/common/component/Lifecycle.java

@@ -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();
     }
+
 }