浏览代码

fix null pointer in audit service client during service shutdown

Jason Rivard 4 年之前
父节点
当前提交
8cb67d8694

+ 1 - 0
onejar/src/main/java/password/pwm/onejar/OnejarMain.java

@@ -117,6 +117,7 @@ public class OnejarMain
             catch ( final OnejarException | ServletException | IOException e )
             {
                 out( "error starting tomcat: " + e.getMessage() );
+                e.printStackTrace();
             }
         }
 

+ 1 - 0
onejar/src/main/java/password/pwm/onejar/TomcatOnejarRunner.java

@@ -73,6 +73,7 @@ public class TomcatOnejarRunner
         }
         catch ( final Exception e )
         {
+            e.printStackTrace();
             if ( e instanceof InvocationTargetException )
             {
                 throw new OnejarException( "error generating keystore: " + e.getCause().getMessage() );

+ 11 - 7
server/src/main/java/password/pwm/svc/event/AuditServiceClient.java

@@ -43,14 +43,18 @@ public class AuditServiceClient
         Objects.requireNonNull( auditRecord );
 
         final AuditService auditService = pwmApplication.getAuditService();
-        try
-        {
-            auditService.submit( sessionLabel, auditRecord );
-        }
-        catch ( final PwmUnrecoverableException e )
+
+        if ( auditService != null )
         {
-            LOGGER.error( sessionLabel, () -> "unexpected error submitting audit event: '"
-                    + JsonUtil.serialize( auditRecord ) + "' , error: " + e.getMessage(), e );
+            try
+            {
+                auditService.submit( sessionLabel, auditRecord );
+            }
+            catch ( final PwmUnrecoverableException e )
+            {
+                LOGGER.error( sessionLabel, () -> "unexpected error submitting audit event: '"
+                        + JsonUtil.serialize( auditRecord ) + "' , error: " + e.getMessage(), e );
+            }
         }
     }