tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1489408 - /tomcat/tc7.0.x/trunk/java/org/apache/juli/FileHandler.java
Date Tue, 04 Jun 2013 12:24:42 GMT
Author: markt
Date: Tue Jun  4 12:24:41 2013
New Revision: 1489408

URL: http://svn.apache.org/r1489408
Log:
Silence some Eclipse warnings

Modified:
    tomcat/tc7.0.x/trunk/java/org/apache/juli/FileHandler.java

Modified: tomcat/tc7.0.x/trunk/java/org/apache/juli/FileHandler.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/juli/FileHandler.java?rev=1489408&r1=1489407&r2=1489408&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/juli/FileHandler.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/juli/FileHandler.java Tue Jun  4 12:24:41 2013
@@ -21,6 +21,7 @@ package org.apache.juli;
 import java.io.BufferedOutputStream;
 import java.io.File;
 import java.io.FileOutputStream;
+import java.io.IOException;
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
 import java.io.PrintWriter;
@@ -372,7 +373,8 @@ public class FileHandler
 
         // Open the current log file
         writerLock.writeLock().lock();
-        try {
+        FileOutputStream fos = null;
+        OutputStream os = null;        try {
             File pathname = new File(dir.getAbsoluteFile(), prefix
                     + (rotatable ? date : "") + suffix);
             File parent = pathname.getParentFile();
@@ -383,8 +385,8 @@ public class FileHandler
                 return;
             }
             String encoding = getEncoding();
-            FileOutputStream fos = new FileOutputStream(pathname, true);
-            OutputStream os = bufferSize>0?new BufferedOutputStream(fos,bufferSize):fos;
+            fos = new FileOutputStream(pathname, true);
+            os = bufferSize>0?new BufferedOutputStream(fos,bufferSize):fos;
             writer = new PrintWriter(
                     (encoding != null) ? new OutputStreamWriter(os, encoding)
                                        : new OutputStreamWriter(os), false);
@@ -392,6 +394,20 @@ public class FileHandler
         } catch (Exception e) {
             reportError(null, e, ErrorManager.OPEN_FAILURE);
             writer = null;
+            if (fos != null) {
+                try {
+                    fos.close();
+                } catch (IOException e1) {
+                    // Ignore
+                }
+            }
+            if (os != null) {
+                try {
+                    os.close();
+                } catch (IOException e1) {
+                    // Ignore
+                }
+            }
         } finally {
             writerLock.writeLock().unlock();
         }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message