geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jsis...@apache.org
Subject svn commit: r412935 - /geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java
Date Fri, 09 Jun 2006 05:26:35 GMT
Author: jsisson
Date: Thu Jun  8 22:26:35 2006
New Revision: 412935

URL: http://svn.apache.org/viewvc?rev=412935&view=rev
Log:
GERONIMO-2095 Fix issue on windows where an IOException may occur when attempting to rename
var\config\config.xml.working to var\config\config.xml . 

Modified:
    geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java

Modified: geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java
URL: http://svn.apache.org/viewvc/geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java?rev=412935&r1=412934&r2=412935&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java
(original)
+++ geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java
Thu Jun  8 22:26:35 2006
@@ -53,6 +53,8 @@
 import java.beans.PropertyEditor;
 import java.io.File;
 import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -458,6 +460,7 @@
                              "http://www.w3.org/2001/XMLSchema");
         dFactory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaSource",
                              LocalAttributeManager.class.getResourceAsStream("/META-INF/schema/local-attributes-1.1.xsd"));
+        FileOutputStream fos = null;
         try {
             Document doc = dFactory.newDocumentBuilder().newDocument();
             serverOverride.writeXml(doc);
@@ -465,11 +468,26 @@
             Transformer xform = xfactory.newTransformer();
             xform.setOutputProperty(OutputKeys.INDENT, "yes");
             xform.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
-            xform.transform(new DOMSource(doc), new StreamResult(file));
+            fos = new FileOutputStream(file);
+            // use a FileOutputStream instead of a File on the StreamResult 
+            // constructor as problems were encountered with the file not being closed.
+            StreamResult sr = new StreamResult(fos); 
+            xform.transform(new DOMSource(doc), sr);
+        } catch (FileNotFoundException e) {
+            // file is directory or cannot be created/opened
+            log.error("Unable to write config.xml", e);
         } catch (ParserConfigurationException e) {
             log.error("Unable to write config.xml", e);
         } catch (TransformerException e) {
             log.error("Unable to write config.xml", e);
+        } finally {
+            if (fos != null) {
+                try {
+                    fos.close();
+                } catch (IOException ignored) {
+                    // ignored
+                }
+            }
         }
     }
 



Mime
View raw message