cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From reinh...@apache.org
Subject svn commit: r652475 - /cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/component/FileReaderComponent.java
Date Thu, 01 May 2008 11:40:11 GMT
Author: reinhard
Date: Thu May  1 04:40:11 2008
New Revision: 652475

URL: http://svn.apache.org/viewvc?rev=652475&view=rev
Log:
. close the input stream in a finally clause

Modified:
    cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/component/FileReaderComponent.java

Modified: cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/component/FileReaderComponent.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/component/FileReaderComponent.java?rev=652475&r1=652474&r2=652475&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/component/FileReaderComponent.java
(original)
+++ cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/component/FileReaderComponent.java
Thu May  1 04:40:11 2008
@@ -66,12 +66,13 @@
      * @see org.apache.cocoon.corona.pipeline.component.Starter#execute()
      */
     public void execute() {
+        InputStream inputStream = null;
         try {
             if (this.source == null) {
                 throw new IllegalArgumentException("FileReaderComponent has no source configured
to read from.");
             }
 
-            InputStream inputStream = this.source.openStream();
+            inputStream = this.source.openStream();
 
             byte[] data = new byte[1024];
             while (true) {
@@ -84,10 +85,15 @@
                 this.outputStream.write(data, 0, bytesRead);
             }
 
-            inputStream.close();
         } catch (IOException e) {
             // TODO: a specific exception is in order
             throw new RuntimeException("FileReader cannot read from '" + this.source + "'",
e);
+        } finally {
+            try {
+                inputStream.close();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
         }
     }
 



Mime
View raw message