cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anto...@apache.org
Subject svn commit: r365301 - /cocoon/trunk/src/java/org/apache/cocoon/transformation/XIncludeTransformer.java
Date Mon, 02 Jan 2006 06:13:09 GMT
Author: antonio
Date: Sun Jan  1 22:13:06 2006
New Revision: 365301

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

Modified:
    cocoon/trunk/src/java/org/apache/cocoon/transformation/XIncludeTransformer.java

Modified: cocoon/trunk/src/java/org/apache/cocoon/transformation/XIncludeTransformer.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/transformation/XIncludeTransformer.java?rev=365301&r1=365300&r2=365301&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/transformation/XIncludeTransformer.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/transformation/XIncludeTransformer.java Sun Jan
 1 22:13:06 2006
@@ -402,15 +402,24 @@
 
                 if (parse.equals("text")) {
                     getLogger().debug("Parse type is text");
-                    InputStream input = url.getInputStream();
-                    Reader reader = new BufferedReader(new InputStreamReader(input));
-                    int read;
-                    char ary[] = new char[1024];
-                    if (reader != null) {
-                        while ((read = reader.read(ary)) != -1) {
-                            super.characters(ary,0,read);
+                    InputStream is = null;
+                    InputStreamReader isr = null;
+                    Reader reader = null;
+                    try {
+                        is = url.getInputStream();
+                        isr = new InputStreamReader(is);
+                        reader = new BufferedReader(isr);
+                        int read;
+                        char ary[] = new char[1024 * 4];
+                        if (reader != null) {
+                            while ((read = reader.read(ary)) != -1) {
+                                super.characters(ary,0,read);
+                            }
                         }
-                        reader.close();
+                    } finally {
+                        if (reader != null) reader.close();
+                        if (isr != null) reader.close();
+                        if (is != null) is.close();
                     }
                 } else if (parse.equals("xml")) {
                     XIncludePipe subPipe = new XIncludePipe();



Mime
View raw message