camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1400833 - in /camel/branches/camel-2.10.x: ./ components/camel-crypto/src/main/java/org/apache/camel/component/crypto/processor/ components/camel-crypto/src/main/java/org/apache/camel/converter/crypto/
Date Mon, 22 Oct 2012 10:26:59 GMT
Author: davsclaus
Date: Mon Oct 22 10:26:59 2012
New Revision: 1400833

URL: http://svn.apache.org/viewvc?rev=1400833&view=rev
Log:
CAMEL-5729: camel-crypto should close strams after usage.

Modified:
    camel/branches/camel-2.10.x/   (props changed)
    camel/branches/camel-2.10.x/components/camel-crypto/src/main/java/org/apache/camel/component/crypto/processor/DigitalSignatureProcessor.java
    camel/branches/camel-2.10.x/components/camel-crypto/src/main/java/org/apache/camel/converter/crypto/CryptoDataFormat.java
    camel/branches/camel-2.10.x/components/camel-crypto/src/main/java/org/apache/camel/converter/crypto/PGPDataFormat.java

Propchange: camel/branches/camel-2.10.x/
------------------------------------------------------------------------------
  Merged /camel/trunk:r1400831

Propchange: camel/branches/camel-2.10.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: camel/branches/camel-2.10.x/components/camel-crypto/src/main/java/org/apache/camel/component/crypto/processor/DigitalSignatureProcessor.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/components/camel-crypto/src/main/java/org/apache/camel/component/crypto/processor/DigitalSignatureProcessor.java?rev=1400833&r1=1400832&r2=1400833&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/components/camel-crypto/src/main/java/org/apache/camel/component/crypto/processor/DigitalSignatureProcessor.java
(original)
+++ camel/branches/camel-2.10.x/components/camel-crypto/src/main/java/org/apache/camel/component/crypto/processor/DigitalSignatureProcessor.java
Mon Oct 22 10:26:59 2012
@@ -30,6 +30,7 @@ import org.apache.camel.Processor;
 import org.apache.camel.component.crypto.DigitalSignatureConfiguration;
 import org.apache.camel.component.crypto.DigitalSignatureConstants;
 import org.apache.camel.util.ExchangeHelper;
+import org.apache.camel.util.IOHelper;
 import org.apache.camel.util.ObjectHelper;
 
 
@@ -45,10 +46,14 @@ public abstract class DigitalSignaturePr
         Object payload = exchange.getIn().getBody();
         if (payload != null) {
             InputStream payloadStream = ExchangeHelper.convertToMandatoryType(exchange, InputStream.class,
payload);
-            byte[] buffer = new byte[config.getBufferSize()];
-            int read;
-            while ((read = payloadStream.read(buffer)) > 0) {
-                signer.update(buffer, 0, read);
+            try {
+                byte[] buffer = new byte[config.getBufferSize()];
+                int read;
+                while ((read = payloadStream.read(buffer)) > 0) {
+                    signer.update(buffer, 0, read);
+                }
+            } finally {
+                IOHelper.close(payloadStream);
             }
         }
     }

Modified: camel/branches/camel-2.10.x/components/camel-crypto/src/main/java/org/apache/camel/converter/crypto/CryptoDataFormat.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/components/camel-crypto/src/main/java/org/apache/camel/converter/crypto/CryptoDataFormat.java?rev=1400833&r1=1400832&r2=1400833&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/components/camel-crypto/src/main/java/org/apache/camel/converter/crypto/CryptoDataFormat.java
(original)
+++ camel/branches/camel-2.10.x/components/camel-crypto/src/main/java/org/apache/camel/converter/crypto/CryptoDataFormat.java
Mon Oct 22 10:26:59 2012
@@ -140,6 +140,7 @@ public class CryptoDataFormat implements
                 }
             } finally {
                 IOHelper.close(cipherStream, "cipher", LOG);
+                IOHelper.close(plaintextStream, "plaintext", LOG);
             }
         }
     }

Modified: camel/branches/camel-2.10.x/components/camel-crypto/src/main/java/org/apache/camel/converter/crypto/PGPDataFormat.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/components/camel-crypto/src/main/java/org/apache/camel/converter/crypto/PGPDataFormat.java?rev=1400833&r1=1400832&r2=1400833&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/components/camel-crypto/src/main/java/org/apache/camel/converter/crypto/PGPDataFormat.java
(original)
+++ camel/branches/camel-2.10.x/components/camel-crypto/src/main/java/org/apache/camel/converter/crypto/PGPDataFormat.java
Mon Oct 22 10:26:59 2012
@@ -120,6 +120,7 @@ public class PGPDataFormat implements Da
         } else {
             enc = (PGPEncryptedDataList) pgpF.nextObject();
         }
+        IOHelper.close(in);
 
         PGPPublicKeyEncryptedData pbe = (PGPPublicKeyEncryptedData) enc.get(0);
         InputStream clear = pbe.getDataStream(key, "BC");
@@ -128,7 +129,15 @@ public class PGPDataFormat implements Da
         PGPCompressedData cData = (PGPCompressedData) pgpFact.nextObject();
         pgpFact = new PGPObjectFactory(cData.getDataStream());
         PGPLiteralData ld = (PGPLiteralData) pgpFact.nextObject();
-        return Streams.readAll(ld.getInputStream());
+
+        byte[] answer;
+        try {
+            answer = Streams.readAll(ld.getInputStream());
+        } finally {
+            IOHelper.close(clear);
+        }
+
+        return answer;
     }
 
     /**



Mime
View raw message