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/05/26 02:11:50 UTC

svn commit: r409514 - /geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/repository/AbstractRepository.java

Author: jsisson
Date: Thu May 25 17:11:49 2006
New Revision: 409514

URL: http://svn.apache.org/viewvc?rev=409514&view=rev
Log:
GERONIMO-2035 - ensure inputstream is closed.

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

Modified: geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/repository/AbstractRepository.java
URL: http://svn.apache.org/viewvc/geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/repository/AbstractRepository.java?rev=409514&r1=409513&r2=409514&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/repository/AbstractRepository.java (original)
+++ geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/repository/AbstractRepository.java Thu May 25 17:11:49 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;