Author: davsclaus
Date: Fri Feb 15 15:15:47 2013
New Revision: 1446627

URL: http://svn.apache.org/r1446627
Log:
CAMEL-6081: gzip data format. Ensure streams is closed to avoid locking files 
on windows.

Modified:
    
camel/trunk/camel-core/src/main/java/org/apache/camel/impl/GzipDataFormat.java

Modified: 
camel/trunk/camel-core/src/main/java/org/apache/camel/impl/GzipDataFormat.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/GzipDataFormat.java?rev=1446627&r1=1446626&r2=1446627&view=diff
==============================================================================
--- 
camel/trunk/camel-core/src/main/java/org/apache/camel/impl/GzipDataFormat.java 
(original)
+++ 
camel/trunk/camel-core/src/main/java/org/apache/camel/impl/GzipDataFormat.java 
Fri Feb 15 15:15:47 2013
@@ -35,21 +35,24 @@ public class GzipDataFormat implements D
         try {
             IOHelper.copy(is, zipOutput);
         } finally {
+            // must close all input streams
             IOHelper.close(is, zipOutput);
         }
     }
 
     public Object unmarshal(Exchange exchange, InputStream stream) throws 
Exception {
         InputStream is = exchange.getIn().getMandatoryBody(InputStream.class);
-        GZIPInputStream unzipInput = new GZIPInputStream(is);
-        
+        GZIPInputStream unzipInput = null;
+
         // Create an expandable byte array to hold the inflated data
         ByteArrayOutputStream bos = new ByteArrayOutputStream();
         try {
+            unzipInput = new GZIPInputStream(is);
             IOHelper.copy(unzipInput, bos);
             return bos.toByteArray();
         } finally {
-            IOHelper.close(unzipInput);
+            // must close all input streams
+            IOHelper.close(unzipInput, is);
         }
     }
 


Reply via email to