Fix a small number of warnings reported by FindBugs.
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sat, 6 Aug 2011 20:00:39 +0000 (20:00 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sat, 6 Aug 2011 20:00:39 +0000 (20:00 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1154574 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/juli/DateFormatCache.java
java/org/apache/juli/FileHandler.java
res/findbugs/filter-false-positives.xml
webapps/docs/changelog.xml

index e8d04b7..3b56ef8 100644 (file)
@@ -53,7 +53,6 @@ public class DateFormatCache {
     /* Number of cached entries */
     private int cacheSize = 0;
 
-    private DateFormatCache parent;
     private Cache cache;
 
     /**
@@ -85,7 +84,6 @@ public class DateFormatCache {
     public DateFormatCache(int size, String format, DateFormatCache parent) {
         cacheSize = size;
         this.format = tidyFormat(format);
-        this.parent = parent;
         Cache parentCache = null;
         if (parent != null) {
             synchronized(parent) {
index 857b87f..0faff81 100644 (file)
@@ -173,12 +173,13 @@ public class FileHandler
         String tsDate = tsString.substring(0, 10);
 
         writerLock.readLock().lock();
-        // If the date has changed, switch log files
-        if (rotatable && !date.equals(tsDate)) {
-            // Update to writeLock before we switch
-            writerLock.readLock().unlock();
-            writerLock.writeLock().lock();
-            try {
+        try {
+            // If the date has changed, switch log files
+            if (rotatable && !date.equals(tsDate)) {
+                // Update to writeLock before we switch
+                writerLock.readLock().unlock();
+                writerLock.writeLock().lock();
+
                 // Make sure another thread hasn't already done this
                 if (!date.equals(tsDate)) {
                     closeWriter();
@@ -188,9 +189,9 @@ public class FileHandler
                 // Down grade to read-lock. This ensures the writer remains valid
                 // until the log message is written
                 writerLock.readLock().lock();
-            } finally {
-                writerLock.writeLock().unlock();
             }
+        } finally {
+            writerLock.writeLock().unlock();
         }
 
         try {
@@ -362,7 +363,12 @@ public class FileHandler
 
         // Create the directory if necessary
         File dir = new File(directory);
-        dir.mkdirs();
+        if (!dir.mkdirs()) {
+            reportError("Unable to create [" + dir + "]", null,
+                    ErrorManager.OPEN_FAILURE);
+            writer = null;
+            return;
+        }
 
         // Open the current log file
         writerLock.writeLock().lock();
@@ -371,7 +377,12 @@ public class FileHandler
                     + (rotatable ? date : "") + suffix);
             File parent = pathname.getParentFile();
             if (!parent.exists()) {
-                parent.mkdirs();
+                if (!parent.mkdirs()) {
+                    reportError("Unable to create [" + parent + "]", null,
+                            ErrorManager.OPEN_FAILURE);
+                    writer = null;
+                    return;
+                }
             }
             String encoding = getEncoding();
             FileOutputStream fos = new FileOutputStream(pathname, true);
index 9ae824d..4667502 100644 (file)
     <Bug code="IS"/>
   </Match>
   <Match>
+    <Class name="org.apache.catalina.authenticator.DigestAuthenticator"/>
+    <Field name="cnonces"/>
+    <Bug code="IS"/>
+  </Match>
+  <Match>
     <Class name="org.apache.catalina.connector.CoyoteReader"/>
     <Method name="readLine"/>
     <Bug code="RR"/>
index 450513e..d55b8db 100644 (file)
         <bug>51621</bug>: Add additional required JARs to the deployer
         distribution. (markt) 
       </fix>
+      <fix>
+        Fix a small number of warnings reported by FindBugs. (markt)
+      </fix>
     </changelog>
   </subsection>
 </section>