Updated Branches:
  refs/heads/camel-2.11.x cf3198722 -> c08056877

Polished the marshal method to instantiate the CipherOutputStream object
only in case plaintextStream is not null.


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

Branch: refs/heads/camel-2.11.x
Commit: c08056877c6700b52a97f1212f2ac7d338189b6c
Parents: cf31987
Author: Babak Vahdat <bvah...@apache.org>
Authored: Sat May 11 23:34:22 2013 +0200
Committer: Babak Vahdat <bvah...@apache.org>
Committed: Sat May 11 23:36:13 2013 +0200

----------------------------------------------------------------------
 .../camel/converter/crypto/CryptoDataFormat.java   |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/c0805687/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 f469980..2b734ad 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
@@ -120,14 +120,15 @@ public class CryptoDataFormat implements DataFormat {
         byte[] iv = getInitializationVector(exchange);
         Key key = getKey(exchange);
 
-        CipherOutputStream cipherStream = new CipherOutputStream(outputStream, 
initializeCipher(ENCRYPT_MODE, key, iv));
         InputStream plaintextStream = 
ExchangeHelper.convertToMandatoryType(exchange, InputStream.class, graph);
         HMACAccumulator hmac = getMessageAuthenticationCode(key);
         if (plaintextStream != null) {
             inlineInitVector(outputStream, iv);
             byte[] buffer = new byte[bufferSize];
             int read;
+            CipherOutputStream cipherStream = null;
             try {
+                cipherStream = new CipherOutputStream(outputStream, 
initializeCipher(ENCRYPT_MODE, key, iv));
                 while ((read = plaintextStream.read(buffer)) > 0) {
                     cipherStream.write(buffer, 0, read);
                     cipherStream.flush();

Reply via email to