cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anto...@apache.org
Subject svn commit: r360456 - /cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/generation/XPathDirectoryGenerator.java
Date Sat, 31 Dec 2005 22:46:11 GMT
Author: antonio
Date: Sat Dec 31 14:46:07 2005
New Revision: 360456

URL: http://svn.apache.org/viewcvs?rev=360456&view=rev
Log:
Close streams.

Modified:
    cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/generation/XPathDirectoryGenerator.java

Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/generation/XPathDirectoryGenerator.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/generation/XPathDirectoryGenerator.java?rev=360456&r1=360455&r2=360456&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/generation/XPathDirectoryGenerator.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/generation/XPathDirectoryGenerator.java
Sat Dec 31 14:46:07 2005
@@ -325,7 +325,7 @@
     }
 
     /**
-     * The MappingInfo class to reolve namespace prefixes to their namespace URI
+     * The MappingInfo class to resolve namespace prefixes to their namespace URI
      *
      * @author <a href="mailto:giacomo(at)apache.org">Giacomo Pati</a>
      * @version CVS $Id$
@@ -360,17 +360,29 @@
             this.mappingSource = mappingSource;
             this.reload = reload;
             prefixMap = new HashMap();
+            InputStreamReader input = null;
+            BufferedReader br = null;
 
-            final BufferedReader br = new BufferedReader(new InputStreamReader(mappingSource.getInputStream()));
-
-            for (String line = br.readLine(); line != null; line = br.readLine()) {
-                final int i = line.indexOf('=');
-
-                if (i > 0) {
-                    final String prefix = line.substring(0, i);
-                    final String namespace = line.substring(i + 1);
-                    prefixMap.put(prefix, namespace);
-                    logger.debug("added mapping: '" + prefix + "'='" + namespace + "'");
+            try {
+                input = new InputStreamReader(mappingSource.getInputStream());
+                br = new BufferedReader(input);
+    
+                for (String line = br.readLine(); line != null; line = br.readLine()) {
+                    final int i = line.indexOf('=');
+    
+                    if (i > 0) {
+                        final String prefix = line.substring(0, i);
+                        final String namespace = line.substring(i + 1);
+                        prefixMap.put(prefix, namespace);
+                        logger.debug("added mapping: '" + prefix + "'='" + namespace + "'");
+                    }
+                }
+            } finally {
+                if (br != null) {
+                    br.close();
+                }
+                if (input != null) {
+                    input.close();
                 }
             }
         }



Mime
View raw message