summaryrefslogtreecommitdiff
path: root/java
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
commite7669a934981d33c93c3257918648fd3d1ec206b (patch)
treeb9c57151750db3e870a232de1bebd99de837cc9c /java
parent1a2b687475a0dec4c6e1932f30f064538b0368e8 (diff)
downloadqpid-python-e7669a934981d33c93c3257918648fd3d1ec206b.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/qpid@805020 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java')
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/logging/management/LoggingManagementMBean.java37
1 files changed, 32 insertions, 5 deletions
diff --git a/java/broker/src/main/java/org/apache/qpid/server/logging/management/LoggingManagementMBean.java b/java/broker/src/main/java/org/apache/qpid/server/logging/management/LoggingManagementMBean.java
index ce7d08c8dc..d98b14e4d5 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/logging/management/LoggingManagementMBean.java
+++ b/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
{