geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jsis...@apache.org
Subject svn commit: r410725 - /geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/repository/AbstractRepository.java
Date Thu, 01 Jun 2006 03:19:10 GMT
Author: jsisson
Date: Wed May 31 20:19:10 2006
New Revision: 410725

URL: http://svn.apache.org/viewvc?rev=410725&view=rev
Log:
GERONIMO-2035 Merge rev 409514 from 1.1 branch to trunk - ensure inputstream is closed.

Modified:
    geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/repository/AbstractRepository.java

Modified: geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/repository/AbstractRepository.java
URL: http://svn.apache.org/viewvc/geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/repository/AbstractRepository.java?rev=410725&r1=410724&r2=410725&view=diff
==============================================================================
--- geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/repository/AbstractRepository.java
(original)
+++ geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/repository/AbstractRepository.java
Wed May 31 20:19:10 2006
@@ -118,31 +118,41 @@
         }
         ClassLoader depCL = new URLClassLoader(new URL[]{url}, ClassLoader.getSystemClassLoader());
         InputStream is = depCL.getResourceAsStream("META-INF/geronimo-dependency.xml");
-        if (is != null) {
-            InputSource in = new InputSource(is);
-            DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
-            dfactory.setNamespaceAware(true);
-            try {
-                Document doc = dfactory.newDocumentBuilder().parse(in);
-                Element root = doc.getDocumentElement();
-                NodeList configs = root.getElementsByTagNameNS(NAMESPACE, "dependency");
-                for (int i = 0; i < configs.getLength(); i++) {
-                    Element dependencyElement = (Element) configs.item(i);
-                    String groupId = getString(dependencyElement, "groupId");
-                    String artifactId = getString(dependencyElement, "artifactId");
-                    String version = getString(dependencyElement, "version");
-                    String type = getString(dependencyElement, "type");
-                    if (type == null) {
-                        type = "jar";
+        try {
+            if (is != null) {
+                InputSource in = new InputSource(is);
+                DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
+                dfactory.setNamespaceAware(true);
+                try {
+                    Document doc = dfactory.newDocumentBuilder().parse(in);
+                    Element root = doc.getDocumentElement();
+                    NodeList configs = root.getElementsByTagNameNS(NAMESPACE, "dependency");
+                    for (int i = 0; i < configs.getLength(); i++) {
+                        Element dependencyElement = (Element) configs.item(i);
+                        String groupId = getString(dependencyElement, "groupId");
+                        String artifactId = getString(dependencyElement, "artifactId");
+                        String version = getString(dependencyElement, "version");
+                        String type = getString(dependencyElement, "type");
+                        if (type == null) {
+                            type = "jar";
+                        }
+                        dependencies.add(new Artifact(groupId, artifactId,  version, type));
                     }
-                    dependencies.add(new Artifact(groupId, artifactId,  version, type));
+                } catch (IOException e) {
+                    throw (IllegalStateException)new IllegalStateException("Unable to parse
geronimo-dependency.xml file in " + url).initCause(e);
+                } catch (ParserConfigurationException e) {
+                    throw (IllegalStateException)new IllegalStateException("Unable to parse
geronimo-dependency.xml file in " + url).initCause(e);
+                } catch (SAXException e) {
+                    throw (IllegalStateException)new IllegalStateException("Unable to parse
geronimo-dependency.xml file in " + url).initCause(e);
+                }
+            }
+        } finally {
+            if (is != null) {
+                try {
+                    is.close();
+                } catch (IOException ignore) {
+                    // ignore
                 }
-            } catch (IOException e) {
-                throw (IllegalStateException)new IllegalStateException("Unable to parse geronimo-dependency.xml
file in " + url).initCause(e);
-            } catch (ParserConfigurationException e) {
-                throw (IllegalStateException)new IllegalStateException("Unable to parse geronimo-dependency.xml
file in " + url).initCause(e);
-            } catch (SAXException e) {
-                throw (IllegalStateException)new IllegalStateException("Unable to parse geronimo-dependency.xml
file in " + url).initCause(e);
             }
         }
         return dependencies;



Mime
View raw message