Ver Fonte

fix issue #518 - Error purging outdated node reference

Jason Rivard há 2 anos atrás
pai
commit
f26b45b2ba

+ 18 - 9
server/src/main/java/password/pwm/svc/node/NodeMachine.java

@@ -158,12 +158,22 @@ class NodeMachine
         @Override
         public void run( )
         {
-            writeNodeStatus();
-            readNodeStatuses();
-            purgeOutdatedNodes();
+            try
+            {
+                writeNodeStatus();
+                readNodeStatuses();
+                purgeOutdatedNodes();
+                lastError = null;
+            }
+            catch ( final PwmUnrecoverableException e )
+            {
+                lastError = e.getErrorInformation();
+                LOGGER.error( e.getErrorInformation() );
+            }
         }
 
         void writeNodeStatus( )
+                throws PwmUnrecoverableException
         {
             try
             {
@@ -175,12 +185,12 @@ class NodeMachine
             {
                 final String errorMsg = "error writing node service heartbeat: " + e.getMessage();
                 final ErrorInformation errorInformation = new ErrorInformation( PwmError.ERROR_NODE_SERVICE_ERROR, errorMsg );
-                lastError = errorInformation;
-                LOGGER.error( lastError );
+                throw new PwmUnrecoverableException( errorInformation );
             }
         }
 
         void readNodeStatuses( )
+                throws PwmUnrecoverableException
         {
             try
             {
@@ -192,12 +202,12 @@ class NodeMachine
             {
                 final String errorMsg = "error reading node statuses: " + e.getMessage();
                 final ErrorInformation errorInformation = new ErrorInformation( PwmError.ERROR_NODE_SERVICE_ERROR, errorMsg );
-                lastError = errorInformation;
-                LOGGER.error( lastError );
+                throw new PwmUnrecoverableException( errorInformation );
             }
         }
 
         void purgeOutdatedNodes( )
+                throws PwmUnrecoverableException
         {
             try
             {
@@ -208,8 +218,7 @@ class NodeMachine
             {
                 final String errorMsg = "error purging outdated node reference: " + e.getMessage();
                 final ErrorInformation errorInformation = new ErrorInformation( PwmError.ERROR_NODE_SERVICE_ERROR, errorMsg );
-                lastError = errorInformation;
-                LOGGER.error( lastError );
+                throw new PwmUnrecoverableException( errorInformation );
             }
         }
     }