You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2011/01/13 14:54:08 UTC
svn commit: r1058556 -
/tomcat/trunk/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java
Author: markt
Date: Thu Jan 13 13:54:08 2011
New Revision: 1058556
URL: http://svn.apache.org/viewvc?rev=1058556&view=rev
Log:
Fix FindBugs warning
Remove unnecessary code
Better error handling
Modified:
tomcat/trunk/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java
Modified: tomcat/trunk/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java?rev=1058556&r1=1058555&r2=1058556&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java (original)
+++ tomcat/trunk/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java Thu Jan 13 13:54:08 2011
@@ -31,7 +31,6 @@ import org.apache.catalina.Engine;
import org.apache.catalina.Globals;
import org.apache.catalina.Host;
import org.apache.catalina.LifecycleException;
-import org.apache.catalina.ha.CatalinaCluster;
import org.apache.catalina.ha.ClusterDeployer;
import org.apache.catalina.ha.ClusterListener;
import org.apache.catalina.ha.ClusterMessage;
@@ -69,8 +68,6 @@ public class FarmWarDeployer extends Clu
private static final String info = "FarmWarDeployer/1.2";
/*--Instance Variables--------------------------------------*/
- protected CatalinaCluster cluster = null;
-
protected boolean started = false; //default 5 seconds
protected HashMap<String, FileMessageFactory> fileFactories =
@@ -244,7 +241,11 @@ public class FarmWarDeployer extends Clu
addServiced(path);
try {
remove(path);
- factory.getFile().renameTo(deployable);
+ if (!factory.getFile().renameTo(deployable)) {
+ log.error("Failed to rename [" +
+ factory.getFile() + "] to [" +
+ deployable + "]");
+ }
check(path);
} finally {
removeServiced(path);
@@ -541,11 +542,15 @@ public class FarmWarDeployer extends Clu
File dir = new File(getAppBase(), baseName);
File xml = new File(configBase, baseName + ".xml");
if (war.exists()) {
- war.delete();
+ if (!war.delete()) {
+ log.error("Failed to delete [" + war + "]");
+ }
} else if (dir.exists()) {
undeployDir(dir);
} else {
- xml.delete();
+ if (!xml.delete()) {
+ log.error("Failed to delete [" + xml + "]");
+ }
}
// Perform new deployment and remove internal HostConfig state
check(path);
@@ -571,11 +576,14 @@ public class FarmWarDeployer extends Clu
if (file.isDirectory()) {
undeployDir(file);
} else {
- file.delete();
+ if (!file.delete()) {
+ log.error("Failed to delete [" + file + "]");
+ }
}
}
- dir.delete();
-
+ if (!dir.delete()) {
+ log.error("Failed to delete [" + dir + "]");
+ }
}
/*
@@ -636,16 +644,6 @@ public class FarmWarDeployer extends Clu
/*--Instance Getters/Setters--------------------------------*/
@Override
- public CatalinaCluster getCluster() {
- return cluster;
- }
-
- @Override
- public void setCluster(CatalinaCluster cluster) {
- this.cluster = cluster;
- }
-
- @Override
public boolean equals(Object listener) {
return super.equals(listener);
}
@@ -722,8 +720,12 @@ public class FarmWarDeployer extends Clu
*/
protected boolean copy(File from, File to) {
try {
- if (!to.exists())
- to.createNewFile();
+ if (!to.exists()) {
+ if (!to.createNewFile()) {
+ log.error("Unable to create [" + to + "]");
+ return false;
+ }
+ }
java.io.FileInputStream is = new java.io.FileInputStream(from);
java.io.FileOutputStream os = new java.io.FileOutputStream(to,
false);
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: svn commit: r1058556 - /tomcat/trunk/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java
Posted by Mark Thomas <ma...@apache.org>.
On 14/01/2011 07:45, Konstantin Kolinko wrote:
> 2011/1/13 <ma...@apache.org>:
>> Author: markt
>> Date: Thu Jan 13 13:54:08 2011
>> New Revision: 1058556
>>
>> URL: http://svn.apache.org/viewvc?rev=1058556&view=rev
>> Log:
>> Fix FindBugs warning
>> Remove unnecessary code
>> Better error handling
>>
>> Modified:
>> tomcat/trunk/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java
>>
>
>
>> @@ -244,7 +241,11 @@ public class FarmWarDeployer extends Clu
>> addServiced(path);
>> try {
>> remove(path);
>> - factory.getFile().renameTo(deployable);
>> + if (!factory.getFile().renameTo(deployable)) {
>> + log.error("Failed to rename [" +
>> + factory.getFile() + "] to [" +
>> + deployable + "]");
> (..)
>
> i18n ?
> It is "error". It will be visible.
I was keeping my changes consistent with the rest of the file - no i18n
is used for the other error messages.
I agree that is not ideal. I'll add going through that file to my to do
list.
Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: svn commit: r1058556 - /tomcat/trunk/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java
Posted by Konstantin Kolinko <kn...@gmail.com>.
2011/1/13 <ma...@apache.org>:
> Author: markt
> Date: Thu Jan 13 13:54:08 2011
> New Revision: 1058556
>
> URL: http://svn.apache.org/viewvc?rev=1058556&view=rev
> Log:
> Fix FindBugs warning
> Remove unnecessary code
> Better error handling
>
> Modified:
> tomcat/trunk/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java
>
> @@ -244,7 +241,11 @@ public class FarmWarDeployer extends Clu
> addServiced(path);
> try {
> remove(path);
> - factory.getFile().renameTo(deployable);
> + if (!factory.getFile().renameTo(deployable)) {
> + log.error("Failed to rename [" +
> + factory.getFile() + "] to [" +
> + deployable + "]");
(..)
i18n ?
It is "error". It will be visible.
Best regards,
Konstantin Kolinko
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org