Fix FindBugs warnings
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sat, 15 Jan 2011 14:00:20 +0000 (14:00 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sat, 15 Jan 2011 14:00:20 +0000 (14:00 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1059337 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/ha/deploy/FarmWarDeployer.java
java/org/apache/catalina/ha/deploy/FileMessageFactory.java
java/org/apache/catalina/ha/deploy/LocalStrings.properties

index 3bdf38f..eb1117e 100644 (file)
@@ -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;
                 }
             }
index c0b7b61..a4d99e9 100644 (file)
@@ -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;
         }
index 216a025..8550c20 100644 (file)
 # 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}]