Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 50293 invoked from network); 12 Jun 2006 09:36:41 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 12 Jun 2006 09:36:41 -0000 Received: (qmail 47061 invoked by uid 500); 12 Jun 2006 09:36:40 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 47000 invoked by uid 500); 12 Jun 2006 09:36:40 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 46986 invoked by uid 99); 12 Jun 2006 09:36:39 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 12 Jun 2006 02:36:39 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 12 Jun 2006 02:36:38 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id ED5961A983A; Mon, 12 Jun 2006 02:36:17 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r413615 - /geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/plugin/PluginInstallerGBean.java Date: Mon, 12 Jun 2006 09:36:17 -0000 To: scm@geronimo.apache.org From: jsisson@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20060612093617.ED5961A983A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N 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 + } + } } } }