summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Gemmell <robbie@apache.org>2009-08-17 15:53:56 +0000
committerRobert Gemmell <robbie@apache.org>2009-08-17 15:53:56 +0000
commit45dec2e0b9238d1a870665abec3df9abbb2aad22 (patch)
treeb9b0aa388c25bf82755509f29081b72a80528f50
parentc6838c9481abaa164f5e839c6f718c616437edf1 (diff)
downloadqpid-python-45dec2e0b9238d1a870665abec3df9abbb2aad22.tar.gz
QPID-2055: update the save process for the log4j configuration file. Check if the rename/move succeeds, and if not attempt a copy instead
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@805020 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/logging/management/LoggingManagementMBean.java37
1 files changed, 32 insertions, 5 deletions
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/management/LoggingManagementMBean.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/management/LoggingManagementMBean.java
index ce7d08c8dc..d98b14e4d5 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/management/LoggingManagementMBean.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/management/LoggingManagementMBean.java
@@ -33,6 +33,7 @@ import java.util.Map;
import org.apache.qpid.management.common.mbeans.LoggingManagement;
import org.apache.qpid.management.common.mbeans.annotations.MBeanDescription;
import org.apache.qpid.server.management.AMQManagedObject;
+import org.apache.qpid.util.FileUtils;
import org.apache.log4j.Level;
import org.apache.log4j.LogManager;
@@ -397,12 +398,12 @@ public class LoggingManagementMBean extends AMQManagedObject implements LoggingM
catch (TransformerException e)
{
_logger.warn("Could not transform the XML into new file: " +e);
- return false;
+ throw new IOException("Could not transform the XML into new file: " +e);
}
catch (IOException e)
{
- _logger.warn("Could not create the new file: " +e);
- return false;
+ _logger.warn("Could not create the new log4j XML file: " +e);
+ throw new IOException("Could not create the new log4j XML file: " +e);
}
// Swap temp file in to replace existing configuration file.
@@ -411,8 +412,34 @@ public class LoggingManagementMBean extends AMQManagedObject implements LoggingM
{
old.delete();
}
- log4jConfigFile.renameTo(old);
- return tmp.renameTo(log4jConfigFile);
+
+ try
+ {
+ if(!log4jConfigFile.renameTo(old))
+ {
+ FileUtils.copyCheckedEx(log4jConfigFile, old);
+ }
+ }
+ catch (IOException e)
+ {
+ _logger.warn("Could not backup the existing log4j XML file: " +e);
+ throw new IOException("Could not backup the existing log4j XML file: " +e);
+ }
+
+ try
+ {
+ if(!tmp.renameTo(log4jConfigFile))
+ {
+ FileUtils.copyCheckedEx(tmp, log4jConfigFile);
+ }
+ }
+ catch (IOException e)
+ {
+ _logger.warn("Could not copy the new configuration into place: " +e);
+ throw new IOException("Could not copy the new configuration into place: " +e);
+ }
+
+ return true;
}
finally
{