camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bvah...@apache.org
Subject git commit: Close the resources properly when done.
Date Sat, 11 May 2013 20:49:15 GMT
Updated Branches:
  refs/heads/camel-2.11.x 951b1c68f -> b2d2ec80a


Close the resources properly when done.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/b2d2ec80
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/b2d2ec80
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/b2d2ec80

Branch: refs/heads/camel-2.11.x
Commit: b2d2ec80a0c9e7eb0c5b5cde688435cc801d58fc
Parents: 951b1c6
Author: Babak Vahdat <bvahdat@apache.org>
Authored: Sat May 11 21:53:06 2013 +0200
Committer: Babak Vahdat <bvahdat@apache.org>
Committed: Sat May 11 22:42:43 2013 +0200

----------------------------------------------------------------------
 .../converter/stream/CachedOutputStreamTest.java   |   12 ++++++
 .../converter/stream/FileInputStreamCacheTest.java |    3 ++
 .../converter/stream/InputStreamCacheTest.java     |    3 ++
 .../camel/converter/stream/ReaderCacheTest.java    |    3 ++
 .../org/apache/camel/util/GroupIteratorTest.java   |    2 +
 .../camel/converter/crypto/CryptoDataFormat.java   |   27 +++++++++------
 .../component/hbase/CamelHBaseTestSupport.java     |    3 ++
 .../component/hbase/HBaseConvertionsTest.java      |    3 ++
 .../camel/component/hbase/HBaseProducerTest.java   |    7 ++++
 .../camel/component/hdfs/HdfsProducerTest.java     |   27 +++++++++++++++
 .../jetty/proxy/JettyChuckedFalseTest.java         |    2 +
 .../component/mongodb/AbstractMongoDbTest.java     |    2 +
 .../processor/aggregate/jdbc/JdbcCamelCodec.java   |   15 ++++++--
 13 files changed, 95 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/b2d2ec80/camel-core/src/test/java/org/apache/camel/converter/stream/CachedOutputStreamTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/converter/stream/CachedOutputStreamTest.java
b/camel-core/src/test/java/org/apache/camel/converter/stream/CachedOutputStreamTest.java
index d0fb684..46316f6 100644
--- a/camel-core/src/test/java/org/apache/camel/converter/stream/CachedOutputStreamTest.java
+++ b/camel-core/src/test/java/org/apache/camel/converter/stream/CachedOutputStreamTest.java
@@ -92,6 +92,8 @@ public class CachedOutputStreamTest extends ContextTestSupport {
 
         files = file.list();
         assertEquals("we should have no temp file", files.length, 0);
+
+        IOHelper.close(cos);
     }
     
     public void testCacheStreamToFileAndCloseStreamEncrypted() throws IOException {
@@ -131,6 +133,8 @@ public class CachedOutputStreamTest extends ContextTestSupport {
 
         files = file.list();
         assertEquals("we should have no temp file", files.length, 0);
+
+        IOHelper.close(cos);
     }
 
     public void testCacheStreamToFileCloseStreamBeforeDone() throws IOException {
@@ -155,6 +159,8 @@ public class CachedOutputStreamTest extends ContextTestSupport {
         
         files = file.list();
         assertEquals("we should have no temp file", files.length, 0);       
+
+        IOHelper.close(cos);
     }
     
     public void testCacheStreamToMemory() throws IOException {
@@ -171,6 +177,8 @@ public class CachedOutputStreamTest extends ContextTestSupport {
         assertTrue("Should get the InputStreamCache", cache instanceof InputStreamCache);
         String temp = IOConverter.toString((InputStream)cache, null);
         assertEquals("Cached a wrong file", temp, TEST_STRING);
+
+        IOHelper.close(cos);
     }
 
     public void testCacheStreamToMemoryAsDiskIsdisabled() throws IOException {
@@ -190,6 +198,8 @@ public class CachedOutputStreamTest extends ContextTestSupport {
         assertEquals("Cached a wrong file", temp, TEST_STRING);
 
         exchange.getUnitOfWork().done(exchange);
+
+        IOHelper.close(cos);
     }
     
     public void testCachedOutputStreamCustomBufferSize() throws IOException {
@@ -220,5 +230,7 @@ public class CachedOutputStreamTest extends ContextTestSupport {
         
         files = file.list();
         assertEquals("we should have no temp file", files.length, 0);       
+
+        IOHelper.close(cos);
     }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/b2d2ec80/camel-core/src/test/java/org/apache/camel/converter/stream/FileInputStreamCacheTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/converter/stream/FileInputStreamCacheTest.java
b/camel-core/src/test/java/org/apache/camel/converter/stream/FileInputStreamCacheTest.java
index 88e0cc2..2468014 100644
--- a/camel-core/src/test/java/org/apache/camel/converter/stream/FileInputStreamCacheTest.java
+++ b/camel-core/src/test/java/org/apache/camel/converter/stream/FileInputStreamCacheTest.java
@@ -20,6 +20,7 @@ import java.io.ByteArrayOutputStream;
 import java.io.File;
 
 import org.apache.camel.ContextTestSupport;
+import org.apache.camel.util.IOHelper;
 
 /**
  * @version 
@@ -39,6 +40,8 @@ public class FileInputStreamCacheTest extends ContextTestSupport {
         String s = context.getTypeConverter().convertTo(String.class, bos);
         assertNotNull(s);
         assertTrue(s.contains("<firstName>James</firstName>"));
+
+        IOHelper.close(cache, bos);
     }
 
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/b2d2ec80/camel-core/src/test/java/org/apache/camel/converter/stream/InputStreamCacheTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/converter/stream/InputStreamCacheTest.java
b/camel-core/src/test/java/org/apache/camel/converter/stream/InputStreamCacheTest.java
index 372edb3..5f02265 100644
--- a/camel-core/src/test/java/org/apache/camel/converter/stream/InputStreamCacheTest.java
+++ b/camel-core/src/test/java/org/apache/camel/converter/stream/InputStreamCacheTest.java
@@ -19,6 +19,7 @@ package org.apache.camel.converter.stream;
 import java.io.ByteArrayOutputStream;
 
 import org.apache.camel.ContextTestSupport;
+import org.apache.camel.util.IOHelper;
 
 /**
  * @version 
@@ -33,6 +34,8 @@ public class InputStreamCacheTest extends ContextTestSupport {
 
         String s = context.getTypeConverter().convertTo(String.class, bos);
         assertEquals("<foo>bar</foo>", s);
+
+        IOHelper.close(cache, bos);
     }
 
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/b2d2ec80/camel-core/src/test/java/org/apache/camel/converter/stream/ReaderCacheTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/converter/stream/ReaderCacheTest.java
b/camel-core/src/test/java/org/apache/camel/converter/stream/ReaderCacheTest.java
index 9d7204f..020ea7a 100644
--- a/camel-core/src/test/java/org/apache/camel/converter/stream/ReaderCacheTest.java
+++ b/camel-core/src/test/java/org/apache/camel/converter/stream/ReaderCacheTest.java
@@ -19,6 +19,7 @@ package org.apache.camel.converter.stream;
 import java.io.ByteArrayOutputStream;
 
 import org.apache.camel.ContextTestSupport;
+import org.apache.camel.util.IOHelper;
 
 /**
  * @version 
@@ -34,6 +35,8 @@ public class ReaderCacheTest extends ContextTestSupport {
 
         String s = context.getTypeConverter().convertTo(String.class, bos);
         assertEquals("<foo>bar</foo>", s);
+
+        IOHelper.close(cache, bos);
     }
 
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/b2d2ec80/camel-core/src/test/java/org/apache/camel/util/GroupIteratorTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/util/GroupIteratorTest.java b/camel-core/src/test/java/org/apache/camel/util/GroupIteratorTest.java
index 68987bf..4dbbac5 100644
--- a/camel-core/src/test/java/org/apache/camel/util/GroupIteratorTest.java
+++ b/camel-core/src/test/java/org/apache/camel/util/GroupIteratorTest.java
@@ -54,6 +54,8 @@ public class GroupIteratorTest extends TestSupport {
         assertEquals("JKL\nMNO\nPQR", gi.next());
         assertEquals("STU\nVW", gi.next());
         assertFalse(gi.hasNext());
+
+        IOHelper.close(gi);
     }
 
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/b2d2ec80/components/camel-crypto/src/main/java/org/apache/camel/converter/crypto/CryptoDataFormat.java
----------------------------------------------------------------------
diff --git a/components/camel-crypto/src/main/java/org/apache/camel/converter/crypto/CryptoDataFormat.java
b/components/camel-crypto/src/main/java/org/apache/camel/converter/crypto/CryptoDataFormat.java
index c28fc3c..4f7b2eb 100644
--- a/components/camel-crypto/src/main/java/org/apache/camel/converter/crypto/CryptoDataFormat.java
+++ b/components/camel-crypto/src/main/java/org/apache/camel/converter/crypto/CryptoDataFormat.java
@@ -150,18 +150,23 @@ public class CryptoDataFormat implements DataFormat {
         if (encryptedStream != null) {
             byte[] iv = getInlinedInitializationVector(exchange, encryptedStream);
             Key key = getKey(exchange);
-            CipherInputStream cipherStream = new CipherInputStream(encryptedStream, initializeCipher(DECRYPT_MODE,
key, iv));
-
-            ByteArrayOutputStream plaintextStream = new ByteArrayOutputStream(bufferSize);
-            HMACAccumulator hmac = getMessageAuthenticationCode(key);
-            byte[] buffer = new byte[bufferSize];
-            hmac.attachStream(plaintextStream);
-            int read;
-            while ((read = cipherStream.read(buffer)) >= 0) {
-                hmac.decryptUpdate(buffer, read);
+            CipherInputStream cipherStream = null;
+            ByteArrayOutputStream plaintextStream = null;
+            try {
+                cipherStream = new CipherInputStream(encryptedStream, initializeCipher(DECRYPT_MODE,
key, iv));
+                plaintextStream = new ByteArrayOutputStream(bufferSize);
+                HMACAccumulator hmac = getMessageAuthenticationCode(key);
+                byte[] buffer = new byte[bufferSize];
+                hmac.attachStream(plaintextStream);
+                int read;
+                while ((read = cipherStream.read(buffer)) >= 0) {
+                    hmac.decryptUpdate(buffer, read);
+                }
+                hmac.validate();
+                unmarshalled = plaintextStream.toByteArray();
+            } finally {
+                IOHelper.close(cipherStream,  plaintextStream);
             }
-            hmac.validate();
-            unmarshalled = plaintextStream.toByteArray();
         }
         return unmarshalled;
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/b2d2ec80/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/CamelHBaseTestSupport.java
----------------------------------------------------------------------
diff --git a/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/CamelHBaseTestSupport.java
b/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/CamelHBaseTestSupport.java
index f43d9cd..e246264 100644
--- a/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/CamelHBaseTestSupport.java
+++ b/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/CamelHBaseTestSupport.java
@@ -21,6 +21,7 @@ import java.io.IOException;
 import org.apache.camel.CamelContext;
 import org.apache.camel.impl.DefaultCamelContext;
 import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.util.IOHelper;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.HBaseTestingUtility;
 import org.apache.hadoop.hbase.client.HTable;
@@ -93,5 +94,7 @@ public abstract class CamelHBaseTestSupport extends CamelTestSupport {
             put.add(family[0].getBytes(), column[0][0].getBytes(), body[r][0][0].getBytes());
             table.put(put);
         }
+
+        IOHelper.close(table);
     }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/b2d2ec80/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/HBaseConvertionsTest.java
----------------------------------------------------------------------
diff --git a/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/HBaseConvertionsTest.java
b/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/HBaseConvertionsTest.java
index 4401652..ab75381 100644
--- a/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/HBaseConvertionsTest.java
+++ b/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/HBaseConvertionsTest.java
@@ -20,6 +20,7 @@ import java.util.HashMap;
 import java.util.Map;
 import org.apache.camel.ProducerTemplate;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.util.IOHelper;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.TableExistsException;
 import org.apache.hadoop.hbase.client.Get;
@@ -105,6 +106,8 @@ public class HBaseConvertionsTest extends CamelHBaseTestSupport {
             result = bar.get(get);
             resultValue = result.value();
             assertArrayEquals(Bytes.toBytes((String) body[2]), resultValue);
+
+            IOHelper.close(bar);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/b2d2ec80/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/HBaseProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/HBaseProducerTest.java
b/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/HBaseProducerTest.java
index c2991bb..6a259b1 100644
--- a/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/HBaseProducerTest.java
+++ b/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/HBaseProducerTest.java
@@ -25,6 +25,7 @@ import org.apache.camel.Exchange;
 import org.apache.camel.ExchangePattern;
 import org.apache.camel.ProducerTemplate;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.util.IOHelper;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.TableExistsException;
 import org.apache.hadoop.hbase.client.Get;
@@ -77,6 +78,8 @@ public class HBaseProducerTest extends CamelHBaseTestSupport {
             Result result = table.get(get);
             byte[] resultValue = result.value();
             assertArrayEquals(body[0][0][0].getBytes(), resultValue);
+
+            IOHelper.close(table);
         }
     }
 
@@ -157,6 +160,8 @@ public class HBaseProducerTest extends CamelHBaseTestSupport {
                 byte[] resultValue = result.value();
                 assertArrayEquals(body[row][0][0].getBytes(), resultValue);
             }
+
+            IOHelper.close(bar);
         }
     }
 
@@ -207,6 +212,8 @@ public class HBaseProducerTest extends CamelHBaseTestSupport {
                 byte[] resultValue = result.value();
                 assertArrayEquals(body[0][col][0].getBytes(), resultValue);
             }
+
+            IOHelper.close(bar);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/b2d2ec80/components/camel-hdfs/src/test/java/org/apache/camel/component/hdfs/HdfsProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-hdfs/src/test/java/org/apache/camel/component/hdfs/HdfsProducerTest.java
b/components/camel-hdfs/src/test/java/org/apache/camel/component/hdfs/HdfsProducerTest.java
index e285b67..09f67a2 100644
--- a/components/camel-hdfs/src/test/java/org/apache/camel/component/hdfs/HdfsProducerTest.java
+++ b/components/camel-hdfs/src/test/java/org/apache/camel/component/hdfs/HdfsProducerTest.java
@@ -19,6 +19,7 @@ package org.apache.camel.component.hdfs;
 import java.io.File;
 
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.util.IOHelper;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
@@ -65,6 +66,8 @@ public class HdfsProducerTest extends HdfsTestSupport {
         Writable value = (Writable) ReflectionUtils.newInstance(reader.getValueClass(), conf);
         reader.next(key, value);
         assertEquals("PAPPO", value.toString());
+
+        IOHelper.close(reader);
     }
 
     @Test
@@ -90,6 +93,8 @@ public class HdfsProducerTest extends HdfsTestSupport {
             assertEquals("PAPPO" + i, txt.toString());
             ++i;
         }
+
+        IOHelper.close(reader);
     }
 
     @Test
@@ -109,6 +114,8 @@ public class HdfsProducerTest extends HdfsTestSupport {
         reader.next(key, value);
         Boolean rBoolean = ((BooleanWritable) value).get();
         assertEquals(rBoolean, aBoolean);
+
+        IOHelper.close(reader);
     }
 
     @Test
@@ -128,6 +135,8 @@ public class HdfsProducerTest extends HdfsTestSupport {
         reader.next(key, value);
         byte rByte = ((ByteWritable) value).get();
         assertEquals(rByte, aByte);
+
+        IOHelper.close(reader);
     }
 
     @Test
@@ -147,6 +156,8 @@ public class HdfsProducerTest extends HdfsTestSupport {
         reader.next(key, value);
         int rInt = ((IntWritable) value).get();
         assertEquals(rInt, anInt);
+
+        IOHelper.close(reader);
     }
 
     @Test
@@ -166,6 +177,8 @@ public class HdfsProducerTest extends HdfsTestSupport {
         reader.next(key, value);
         float rFloat = ((FloatWritable) value).get();
         assertEquals(rFloat, aFloat, 0.0F);
+
+        IOHelper.close(reader);
     }
 
     @Test
@@ -185,6 +198,8 @@ public class HdfsProducerTest extends HdfsTestSupport {
         reader.next(key, value);
         Double rDouble = ((DoubleWritable) value).get();
         assertEquals(rDouble, aDouble);
+
+        IOHelper.close(reader);
     }
 
     @Test
@@ -204,6 +219,8 @@ public class HdfsProducerTest extends HdfsTestSupport {
         reader.next(key, value);
         long rLong = ((LongWritable) value).get();
         assertEquals(rLong, aLong);
+
+        IOHelper.close(reader);
     }
 
     @Test
@@ -223,6 +240,8 @@ public class HdfsProducerTest extends HdfsTestSupport {
         reader.next(key, value);
         String rTxt = value.toString();
         assertEquals(rTxt, txt);
+
+        IOHelper.close(reader);
     }
 
     @Test
@@ -243,6 +262,8 @@ public class HdfsProducerTest extends HdfsTestSupport {
         reader.next(key, value);
         assertEquals(key.toString(), txtKey);
         assertEquals(value.toString(), txtValue);
+
+        IOHelper.close(reader);
     }
 
     @Test
@@ -263,6 +284,8 @@ public class HdfsProducerTest extends HdfsTestSupport {
         reader.next(key, value);
         assertEquals(key.toString(), txtKey);
         assertEquals(value.toString(), txtValue);
+
+        IOHelper.close(reader);
     }
 
     @Test
@@ -280,6 +303,8 @@ public class HdfsProducerTest extends HdfsTestSupport {
         Text value = (Text) ReflectionUtils.newInstance(reader.getValueClass(), conf);
         reader.next(value);
         assertEquals(value.toString(), txtValue);
+
+        IOHelper.close(reader);
     }
 
     @Test
@@ -300,6 +325,8 @@ public class HdfsProducerTest extends HdfsTestSupport {
         reader.next(key, value);
         assertEquals(key.toString(), txtKey);
         assertEquals(value.toString(), txtValue);
+
+        IOHelper.close(reader);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/camel/blob/b2d2ec80/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/proxy/JettyChuckedFalseTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/proxy/JettyChuckedFalseTest.java
b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/proxy/JettyChuckedFalseTest.java
index 83ace92..ebcc556 100644
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/proxy/JettyChuckedFalseTest.java
+++ b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/proxy/JettyChuckedFalseTest.java
@@ -22,6 +22,7 @@ import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.jetty.BaseJettyTest;
 import org.apache.camel.converter.stream.CachedOutputStream;
+import org.apache.camel.util.IOHelper;
 import org.junit.Test;
 
 public class JettyChuckedFalseTest extends BaseJettyTest {
@@ -59,6 +60,7 @@ public class JettyChuckedFalseTest extends BaseJettyTest {
                         CachedOutputStream stream = new CachedOutputStream(exchange);
                         stream.write("This is hello world.".getBytes());
                         exchange.getOut().setBody(stream.getInputStream());
+                        IOHelper.close(stream);
                     }
                 });
             }

http://git-wip-us.apache.org/repos/asf/camel/blob/b2d2ec80/components/camel-mongodb/src/test/java/org/apache/camel/component/mongodb/AbstractMongoDbTest.java
----------------------------------------------------------------------
diff --git a/components/camel-mongodb/src/test/java/org/apache/camel/component/mongodb/AbstractMongoDbTest.java
b/components/camel-mongodb/src/test/java/org/apache/camel/component/mongodb/AbstractMongoDbTest.java
index f789da2..f6f4698 100644
--- a/components/camel-mongodb/src/test/java/org/apache/camel/component/mongodb/AbstractMongoDbTest.java
+++ b/components/camel-mongodb/src/test/java/org/apache/camel/component/mongodb/AbstractMongoDbTest.java
@@ -34,6 +34,7 @@ import org.apache.camel.CamelExecutionException;
 import org.apache.camel.component.properties.PropertiesComponent;
 import org.apache.camel.spring.SpringCamelContext;
 import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.util.IOHelper;
 import org.apache.camel.util.ObjectHelper;
 
 import org.junit.After;
@@ -119,6 +120,7 @@ public abstract class AbstractMongoDbTest extends CamelTestSupport {
             int index = i % scientists.length;
             Formatter f = new Formatter();
             String doc = f.format("{\"_id\":\"%d\", \"scientist\":\"%s\", \"fixedField\":
\"fixedValue\"}", i, scientists[index]).toString();
+            IOHelper.close(f);
             testCollection.insert((DBObject) JSON.parse(doc), WriteConcern.SAFE);
         }
         assertEquals("Data pumping of 1000 entries did not complete entirely", 1000L, testCollection.count());

http://git-wip-us.apache.org/repos/asf/camel/blob/b2d2ec80/components/camel-sql/src/main/java/org/apache/camel/processor/aggregate/jdbc/JdbcCamelCodec.java
----------------------------------------------------------------------
diff --git a/components/camel-sql/src/main/java/org/apache/camel/processor/aggregate/jdbc/JdbcCamelCodec.java
b/components/camel-sql/src/main/java/org/apache/camel/processor/aggregate/jdbc/JdbcCamelCodec.java
index 2369cbd..7244ee3 100644
--- a/components/camel-sql/src/main/java/org/apache/camel/processor/aggregate/jdbc/JdbcCamelCodec.java
+++ b/components/camel-sql/src/main/java/org/apache/camel/processor/aggregate/jdbc/JdbcCamelCodec.java
@@ -27,6 +27,7 @@ import org.apache.camel.Endpoint;
 import org.apache.camel.Exchange;
 import org.apache.camel.impl.DefaultExchange;
 import org.apache.camel.impl.DefaultExchangeHolder;
+import org.apache.camel.util.IOHelper;
 
 /**
  * Adapted from HawtDBCamelCodec
@@ -76,9 +77,17 @@ public class JdbcCamelCodec {
 
     private DefaultExchangeHolder decode(CamelContext camelContext, byte[] dataIn) throws
IOException, ClassNotFoundException {
         ByteArrayInputStream bytesIn = new ByteArrayInputStream(dataIn);
-        ObjectInputStream objectIn = new ClassLoadingAwareObjectInputStream(camelContext,
bytesIn);
-        Object obj = objectIn.readObject();
-        return (DefaultExchangeHolder) obj;
+
+        ObjectInputStream objectIn = null;
+        Object obj = null;
+        try {
+            objectIn = new ClassLoadingAwareObjectInputStream(camelContext, bytesIn);
+            obj = objectIn.readObject();
+        } finally {
+            IOHelper.close(objectIn);
+        }
+
+        return (DefaultExchangeHolder)obj;
     }
 
 }


Mime
View raw message