From 5f7f6e4b0cdb76ed67381f41576bcdebb34218ff Mon Sep 17 00:00:00 2001 From: markt Date: Sat, 6 Aug 2011 20:00:39 +0000 Subject: [PATCH] Fix a small number of warnings reported by FindBugs. git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1154574 13f79535-47bb-0310-9956-ffa450edef68 --- java/org/apache/juli/DateFormatCache.java | 2 -- java/org/apache/juli/FileHandler.java | 31 +++++++++++++++++++++---------- res/findbugs/filter-false-positives.xml | 5 +++++ webapps/docs/changelog.xml | 3 +++ 4 files changed, 29 insertions(+), 12 deletions(-) diff --git a/java/org/apache/juli/DateFormatCache.java b/java/org/apache/juli/DateFormatCache.java index e8d04b774..3b56ef88f 100644 --- a/java/org/apache/juli/DateFormatCache.java +++ b/java/org/apache/juli/DateFormatCache.java @@ -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) { diff --git a/java/org/apache/juli/FileHandler.java b/java/org/apache/juli/FileHandler.java index 857b87f49..0faff81a3 100644 --- a/java/org/apache/juli/FileHandler.java +++ b/java/org/apache/juli/FileHandler.java @@ -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); diff --git a/res/findbugs/filter-false-positives.xml b/res/findbugs/filter-false-positives.xml index 9ae824dfb..466750231 100644 --- a/res/findbugs/filter-false-positives.xml +++ b/res/findbugs/filter-false-positives.xml @@ -52,6 +52,11 @@ + + + + + diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 450513e44..d55b8db20 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -293,6 +293,9 @@ 51621: Add additional required JARs to the deployer distribution. (markt) + + Fix a small number of warnings reported by FindBugs. (markt) + -- 2.11.0