From: markt Date: Sat, 15 Jan 2011 14:00:20 +0000 (+0000) Subject: Fix FindBugs warnings X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=b3c57bda134db05ce52b5d772474a916b18df6d6;p=tomcat7.0 Fix FindBugs warnings git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1059337 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java b/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java index 3bdf38fe4..eb1117e71 100644 --- a/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java +++ b/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java @@ -732,7 +732,7 @@ public class FarmWarDeployer extends ClusterListener try { if (!to.exists()) { if (!to.createNewFile()) { - log.error(sm.getString("farmWarDeployer.fileNewFail", to)); + log.error(sm.getString("fileNewFail", to)); return false; } } diff --git a/java/org/apache/catalina/ha/deploy/FileMessageFactory.java b/java/org/apache/catalina/ha/deploy/FileMessageFactory.java index c0b7b61f2..a4d99e9fe 100644 --- a/java/org/apache/catalina/ha/deploy/FileMessageFactory.java +++ b/java/org/apache/catalina/ha/deploy/FileMessageFactory.java @@ -29,6 +29,7 @@ import java.util.concurrent.atomic.AtomicLong; import org.apache.juli.logging.Log; import org.apache.juli.logging.LogFactory; import org.apache.tomcat.util.buf.HexUtils; +import org.apache.tomcat.util.res.StringManager; /** * This factory is used to read files and write files by splitting them up into @@ -47,6 +48,8 @@ import org.apache.tomcat.util.buf.HexUtils; public class FileMessageFactory { /*--Static Variables----------------------------------------*/ private static final Log log = LogFactory.getLog(FileMessageFactory.class); + private static final StringManager sm = + StringManager.getManager(Constants.Package); /** * The number of bytes that we read from file @@ -144,7 +147,9 @@ public class FileMessageFactory { log.debug("open file " + f + " write " + openForWrite); if (openForWrite) { if (!file.exists()) - file.createNewFile(); + if (!file.createNewFile()) { + throw new IOException(sm.getString("fileNewFail", file)); + } out = new FileOutputStream(f); } else { size = file.length(); @@ -238,7 +243,7 @@ public class FileMessageFactory { + " war: " + msg.getFileName() + " data: " - + msg.getData() + + HexUtils.toHexString(msg.getData()) + " data length: " + msg.getDataLength() + " ]"); return false; } @@ -252,7 +257,7 @@ public class FileMessageFactory { + " war: " + msg.getFileName() + " data: " - + msg.getData() + + HexUtils.toHexString(msg.getData()) + " data length: " + msg.getDataLength() + " ]"); return false; } diff --git a/java/org/apache/catalina/ha/deploy/LocalStrings.properties b/java/org/apache/catalina/ha/deploy/LocalStrings.properties index 216a025b3..8550c20da 100644 --- a/java/org/apache/catalina/ha/deploy/LocalStrings.properties +++ b/java/org/apache/catalina/ha/deploy/LocalStrings.properties @@ -13,10 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. +fileNewFail=Unable to create [{0}] + farmWarDeployer.deleteFail=Failed to delete [{0}] farmWarDeployer.deployEnd=Deployment from [{0}] finished. farmWarDeployer.fileCopyFail=Unable to copy from [{0}] to [{1}] -farmWarDeployer.fileNewFail=Unable to create [{0}] farmWarDeployer.hostOnly=FarmWarDeployer can only work as host cluster subelement! farmWarDeployer.hostParentEngine=FarmWarDeployer can only work if parent of [{0}] is an engine! farmWarDeployer.mbeanNameFail=Can't construct MBean object name for engine [{0}] and host [{1}]