xmlgraphics-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jerem...@apache.org
Subject svn commit: r752408 - in /xmlgraphics/commons/trunk: src/java/org/apache/xmlgraphics/util/Service.java status.xml
Date Wed, 11 Mar 2009 08:48:22 GMT
Author: jeremias
Date: Wed Mar 11 08:48:21 2009
New Revision: 752408

URL: http://svn.apache.org/viewvc?rev=752408&view=rev
Log:
Bugfix: Streams were not closed in Service class. This prohibited unloading XML Graphics Commons.

Modified:
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/util/Service.java
    xmlgraphics/commons/trunk/status.xml

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/util/Service.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/util/Service.java?rev=752408&r1=752407&r2=752408&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/util/Service.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/util/Service.java Wed Mar 11
08:48:21 2009
@@ -30,6 +30,8 @@
 import java.util.List;
 import java.util.Map;
 
+import org.apache.commons.io.IOUtils;
+
 /**
  * This class handles looking up service providers on the class path.
  * It implements the system described in:
@@ -94,11 +96,17 @@
             // Ooops! can't get his class loader.
         }
         // Can always request your own class loader. But it might be 'null'.
-        if (cl == null) cl = Service.class.getClassLoader();
-        if (cl == null) cl = ClassLoader.getSystemClassLoader();
+        if (cl == null) {
+            cl = Service.class.getClassLoader();
+        }
+        if (cl == null) {
+            cl = ClassLoader.getSystemClassLoader();
+        }
 
         // No class loader so we can't find 'serviceFile'.
-        if (cl == null) return l.iterator();
+        if (cl == null) {
+            return l.iterator();
+        }
 
         Enumeration e;
         try {
@@ -114,36 +122,41 @@
                 InputStream    is = u.openStream();
                 Reader         r  = new InputStreamReader(is, "UTF-8");
                 BufferedReader br = new BufferedReader(r);
-
-                String line = br.readLine();
-                while (line != null) {
-                    try {
-                        // First strip any comment...
-                        int idx = line.indexOf('#');
-                        if (idx != -1)
-                            line = line.substring(0, idx);
-
-                        // Trim whitespace.
-                        line = line.trim();
-
-                        // If nothing left then loop around...
-                        if (line.length() == 0) {
-                            line = br.readLine();
-                            continue;
-                        }
-
-                        if (returnInstances) {
-                            // Try and load the class
-                            Object obj = cl.loadClass(line).newInstance();
-                            // stick it into our vector...
-                            l.add(obj);
-                        } else {
-                            l.add(line);
+                try {
+                    String line = br.readLine();
+                    while (line != null) {
+                        try {
+                            // First strip any comment...
+                            int idx = line.indexOf('#');
+                            if (idx != -1) {
+                                line = line.substring(0, idx);
+                            }
+
+                            // Trim whitespace.
+                            line = line.trim();
+
+                            // If nothing left then loop around...
+                            if (line.length() == 0) {
+                                line = br.readLine();
+                                continue;
+                            }
+
+                            if (returnInstances) {
+                                // Try and load the class
+                                Object obj = cl.loadClass(line).newInstance();
+                                // stick it into our vector...
+                                l.add(obj);
+                            } else {
+                                l.add(line);
+                            }
+                        } catch (Exception ex) {
+                            // Just try the next line
                         }
-                    } catch (Exception ex) {
-                        // Just try the next line
+                        line = br.readLine();
                     }
-                    line = br.readLine();
+                } finally {
+                    IOUtils.closeQuietly(br);
+                    IOUtils.closeQuietly(is);
                 }
             } catch (Exception ex) {
                 // Just try the next file...

Modified: xmlgraphics/commons/trunk/status.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/status.xml?rev=752408&r1=752407&r2=752408&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/status.xml (original)
+++ xmlgraphics/commons/trunk/status.xml Wed Mar 11 08:48:21 2009
@@ -41,6 +41,9 @@
   <changes>
     <release version="Trunk" date="n/a">
       <action context="Code" dev="JM" type="fix">
+        Bugfix: Streams were not closed in Service class.
+      </action>
+      <action context="Code" dev="JM" type="fix">
         Catching IllegalArgumentException in XMPSerializer when the Transformer implementation
         in use doesn't support the INDENT key.
       </action>



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: commits-help@xmlgraphics.apache.org


Mime
View raw message