You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ro...@apache.org on 2009/08/17 17:53:56 UTC

svn commit: r805020 - /qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/management/LoggingManagementMBean.java

Author: robbie
Date: Mon Aug 17 15:53:56 2009
New Revision: 805020

URL: http://svn.apache.org/viewvc?rev=805020&view=rev
Log:
QPID-2055: update the save process for the log4j configuration file. Check if the rename/move succeeds, and if not attempt a copy instead

Modified:
    qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/management/LoggingManagementMBean.java

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/management/LoggingManagementMBean.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/management/LoggingManagementMBean.java?rev=805020&r1=805019&r2=805020&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/management/LoggingManagementMBean.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/management/LoggingManagementMBean.java Mon Aug 17 15:53:56 2009
@@ -33,6 +33,7 @@
 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 @@
             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 @@
             {
                 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
         {



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org