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/12 11:36:17 UTC
svn commit: r413615 -
/geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/plugin/PluginInstallerGBean.java
Author: jsisson
Date: Mon Jun 12 02:36:17 2006
New Revision: 413615
URL: http://svn.apache.org/viewvc?rev=413615&view=rev
Log:
GERONIMO-2096 (merge from 1.1 branch) Fix issue where PluginInstallerGBean.updatePluginMetadata(..) may leave geronimo-plugin.xml file open
Modified:
geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/plugin/PluginInstallerGBean.java
Modified: geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/plugin/PluginInstallerGBean.java
URL: http://svn.apache.org/viewvc/geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/plugin/PluginInstallerGBean.java?rev=413615&r1=413614&r2=413615&view=diff
==============================================================================
--- geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/plugin/PluginInstallerGBean.java (original)
+++ geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/plugin/PluginInstallerGBean.java Mon Jun 12 02:36:17 2006
@@ -260,11 +260,11 @@
Manifest manifest = input.getManifest();
JarOutputStream out = manifest == null ? new JarOutputStream(new BufferedOutputStream(new FileOutputStream(temp)))
: new JarOutputStream(new BufferedOutputStream(new FileOutputStream(temp)), manifest);
- Enumeration enum = input.entries();
+ Enumeration en = input.entries();
byte[] buf = new byte[4096];
int count;
- while (enum.hasMoreElements()) {
- JarEntry entry = (JarEntry) enum.nextElement();
+ while (en.hasMoreElements()) {
+ JarEntry entry = (JarEntry) en.nextElement();
if(entry.getName().equals("META-INF/geronimo-plugin.xml")) {
entry = new JarEntry(entry.getName());
out.putNextEntry(entry);
@@ -298,13 +298,14 @@
} catch (Exception e) {
log.error("Unable to update plugin metadata", e);
throw new RuntimeException("Unable to update plugin metadata", e);
- }
+ } // TODO this really should have a finally block to ensure streams are closed
} else {
File meta = new File(dir, "META-INF");
if(!meta.isDirectory() || !meta.canRead()) {
throw new IllegalArgumentException(metadata.getModuleId()+" is not a plugin!");
}
File xml = new File(meta, "geronimo-plugin.xml");
+ FileOutputStream fos = null;
try {
if(!xml.isFile()) {
if(!xml.createNewFile()) {
@@ -316,9 +317,21 @@
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(xml));
+ fos = new FileOutputStream(xml);
+ // 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 (Exception e) {
log.error("Unable to save plugin metadata for "+metadata.getModuleId(), e);
+ } finally {
+ if (fos != null) {
+ try {
+ fos.close();
+ } catch (IOException ignored) {
+ // ignored
+ }
+ }
}
}
}