You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by js...@apache.org on 2006/06/09 07:46:39 UTC
svn commit: r412939 -
/geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java
Author: jsisson
Date: Thu Jun 8 22:46:39 2006
New Revision: 412939
URL: http://svn.apache.org/viewvc?rev=412939&view=rev
Log:
GERONIMO-2095 (Merge from 1.1 branch) 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/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java
Modified: geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java
URL: http://svn.apache.org/viewvc/geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java?rev=412939&r1=412938&r2=412939&view=diff
==============================================================================
--- geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java (original)
+++ geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java Thu Jun 8 22:46:39 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
+ }
+ }
}
}