prevent NPE during shutdown where the logger has been shutdown and delayed resources...
authorfhanik <fhanik@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 10 Jun 2008 17:43:28 +0000 (17:43 +0000)
committerfhanik <fhanik@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 10 Jun 2008 17:43:28 +0000 (17:43 +0000)
java.lang.NullPointerException
at org.apache.juli.FileHandler.publish(FileHandler.java:136)

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@666232 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/juli/FileHandler.java

index 587440f..eb23fb5 100644 (file)
@@ -133,8 +133,12 @@ public class FileHandler
         }
         
         try {
-            writer.write(result);
-            writer.flush();
+            if (writer!=null) {
+                writer.write(result);
+                writer.flush();
+            } else {
+                reportError("FileHandler is closed or not yet initialized, unable to log ["+result+"]", null, ErrorManager.WRITE_FAILURE);
+            }
         } catch (Exception e) {
             reportError(null, e, ErrorManager.WRITE_FAILURE);
             return;