Franz Forsthofer created CAMEL-16177:
----------------------------------------

             Summary: File stream cache problem with multicast parallel 
processing and encrypted stream
                 Key: CAMEL-16177
                 URL: https://issues.apache.org/jira/browse/CAMEL-16177
             Project: Camel
          Issue Type: Bug
          Components: camel-core
    Affects Versions: 3.7.2
            Reporter: Franz Forsthofer
             Fix For: 3.7.3, 3.8.0


If you use stream caching with file encryption in a camel route where you have 
a multicast with several branches, then it the following errors can happen in 
the message processing of the branch.
 * When the message is processed in a branch you can get the following 
exception:aused by: java.lang.ArrayIndexOutOfBoundsException: while trying to 
load from index 16 of a byte (or boolean) array with length 16, loaded from 
field com.sun.crypto.provider.CounterMode.encryptedCounter of an object loaded 
from local variable 'this'aused by: java.lang.ArrayIndexOutOfBoundsException: 
while trying to load from index 16 of a byte (or boolean) array with length 16, 
loaded from field com.sun.crypto.provider.CounterMode.encryptedCounter of an 
object loaded from local variable 'this' at 
com.sun.crypto.provider.CounterMode.implCrypt(CounterMode.java:190) at 
com.sun.crypto.provider.CounterMode.crypt(CounterMode.java:178) at 
com.sun.crypto.provider.CounterMode.decrypt(CounterMode.java:153) at 
com.sun.crypto.provider.CipherCore.update(CipherCore.java:782) at 
com.sun.crypto.provider.CipherCore.update(CipherCore.java:667) at 
com.sun.crypto.provider.AESCipher.engineUpdate(AESCipher.java:380) at 
javax.crypto.Cipher.update(Cipher.java:1835) at 
javax.crypto.CipherInputStream.getMoreData(CipherInputStream.java:139) at 
javax.crypto.CipherInputStream.read(CipherInputStream.java:199) at 
org.apache.camel.converter.stream.FileInputStreamCache.read(FileInputStreamCache.java:139)
 * or you get a damaged payload in the branch which is not correctly decrypted

The root cause of the problem is that the decryptor is not thread safe: If two 
different FileInputStreamCache instances use the same decryptor in two 
different threads at the same time, the above problems occur.

I will provide a patch for this problem.

 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to