You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2021/02/10 15:13:19 UTC

[GitHub] [camel] forsthofer opened a new pull request #5065: CAMEL-16177: multicast parallel processing and encrypted stream cache

forsthofer opened a new pull request #5065:
URL: https://github.com/apache/camel/pull/5065


   - [x] Make sure there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for the change (usually before you start working on it).  Trivial changes like typos do not require a JIRA issue.  Your pull request should address just this issue, without pulling in other changes.
   - [x] Each commit in the pull request should have a meaningful subject line and body.
   - [ ] If you're unsure, you can format the pull request title like `[CAMEL-XXX] Fixes bug in camel-file component`, where you replace `CAMEL-XXX` with the appropriate JIRA issue.
   - [ ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
   - [ ] Run `mvn clean install -Psourcecheck` in your module with source check enabled to make sure basic checks pass and there are no checkstyle violations. A more thorough check will be performed on your pull request automatically.
   Below are the contribution guidelines:
   https://github.com/apache/camel/blob/master/CONTRIBUTING.md


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel] forsthofer commented on a change in pull request #5065: CAMEL-16177: multicast parallel processing and encrypted stream cache

Posted by GitBox <gi...@apache.org>.
forsthofer commented on a change in pull request #5065:
URL: https://github.com/apache/camel/pull/5065#discussion_r573833374



##########
File path: core/camel-support/src/main/java/org/apache/camel/converter/stream/CipherPair.java
##########
@@ -61,7 +60,18 @@ public Cipher getEncryptor() {
         return enccipher;
     }
 
-    public Cipher getDecryptor() {
-        return deccipher;
+    /**
+     * Create the decryptor every time because the decryptor is not thead safe. For example, if you reuse the decryptor
+     * instance in the Multi-cast case then you will get errors.
+     */
+    public Cipher createDecryptor() {
+        try {
+            Cipher deccipher = Cipher.getInstance(transformation);
+            deccipher.init(Cipher.DECRYPT_MODE, key, ivp == null ? null : new IvParameterSpec(ivp));
+            return deccipher;
+        } catch (GeneralSecurityException e) {
+            // should not happen
+            throw new IllegalStateException("Could not instantiate decryptor, e");

Review comment:
       We could wrap the GenealSecurityException into an IOException and throw the IOException because this exception is also used in FileInputStreamCache, the only class which uses the createDecryptor method




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel] davsclaus merged pull request #5065: CAMEL-16177: multicast parallel processing and encrypted stream cache

Posted by GitBox <gi...@apache.org>.
davsclaus merged pull request #5065:
URL: https://github.com/apache/camel/pull/5065


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel] forsthofer commented on a change in pull request #5065: CAMEL-16177: multicast parallel processing and encrypted stream cache

Posted by GitBox <gi...@apache.org>.
forsthofer commented on a change in pull request #5065:
URL: https://github.com/apache/camel/pull/5065#discussion_r574439710



##########
File path: core/camel-support/src/main/java/org/apache/camel/converter/stream/CipherPair.java
##########
@@ -71,7 +71,7 @@ public Cipher createDecryptor() {
             return deccipher;
         } catch (GeneralSecurityException e) {
             // should not happen
-            throw new IllegalStateException("Could not instantiate decryptor, e");
+            throw new IllegalStateException("Could not instanciate decryptor, e");

Review comment:
       Hi, sorry I was blind. I corrected this in a separate commit.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel] davsclaus commented on a change in pull request #5065: CAMEL-16177: multicast parallel processing and encrypted stream cache

Posted by GitBox <gi...@apache.org>.
davsclaus commented on a change in pull request #5065:
URL: https://github.com/apache/camel/pull/5065#discussion_r574266634



##########
File path: core/camel-support/src/main/java/org/apache/camel/converter/stream/CipherPair.java
##########
@@ -71,7 +71,7 @@ public Cipher createDecryptor() {
             return deccipher;
         } catch (GeneralSecurityException e) {
             // should not happen
-            throw new IllegalStateException("Could not instantiate decryptor, e");
+            throw new IllegalStateException("Could not instanciate decryptor, e");

Review comment:
       throw new IllegalStateException("Could not instanciate decryptor, e");
   
   ->
   
   throw new IllegalStateException("Could not instanciate decryptor", e);




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel] davsclaus commented on a change in pull request #5065: CAMEL-16177: multicast parallel processing and encrypted stream cache

Posted by GitBox <gi...@apache.org>.
davsclaus commented on a change in pull request #5065:
URL: https://github.com/apache/camel/pull/5065#discussion_r573838885



##########
File path: core/camel-support/src/main/java/org/apache/camel/converter/stream/CipherPair.java
##########
@@ -61,7 +60,18 @@ public Cipher getEncryptor() {
         return enccipher;
     }
 
-    public Cipher getDecryptor() {
-        return deccipher;
+    /**
+     * Create the decryptor every time because the decryptor is not thead safe. For example, if you reuse the decryptor
+     * instance in the Multi-cast case then you will get errors.
+     */
+    public Cipher createDecryptor() {
+        try {
+            Cipher deccipher = Cipher.getInstance(transformation);
+            deccipher.init(Cipher.DECRYPT_MODE, key, ivp == null ? null : new IvParameterSpec(ivp));
+            return deccipher;
+        } catch (GeneralSecurityException e) {
+            // should not happen
+            throw new IllegalStateException("Could not instantiate decryptor, e");

Review comment:
       I mean look at the exception message
   
   throw new IllegalStateException("Could not instantiate decryptor, e");
   
   should be
   
   throw new IllegalStateException("Could not instantiate decryptor", e);




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel] davsclaus commented on a change in pull request #5065: CAMEL-16177: multicast parallel processing and encrypted stream cache

Posted by GitBox <gi...@apache.org>.
davsclaus commented on a change in pull request #5065:
URL: https://github.com/apache/camel/pull/5065#discussion_r573818541



##########
File path: core/camel-support/src/main/java/org/apache/camel/converter/stream/CipherPair.java
##########
@@ -61,7 +60,18 @@ public Cipher getEncryptor() {
         return enccipher;
     }
 
-    public Cipher getDecryptor() {
-        return deccipher;
+    /**
+     * Create the decryptor every time because the decryptor is not thead safe. For example, if you reuse the decryptor
+     * instance in the Multi-cast case then you will get errors.
+     */
+    public Cipher createDecryptor() {
+        try {
+            Cipher deccipher = Cipher.getInstance(transformation);
+            deccipher.init(Cipher.DECRYPT_MODE, key, ivp == null ? null : new IvParameterSpec(ivp));
+            return deccipher;
+        } catch (GeneralSecurityException e) {
+            // should not happen
+            throw new IllegalStateException("Could not instantiate decryptor, e");

Review comment:
       There is a little bug here with the caused exception




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel] forsthofer commented on a change in pull request #5065: CAMEL-16177: multicast parallel processing and encrypted stream cache

Posted by GitBox <gi...@apache.org>.
forsthofer commented on a change in pull request #5065:
URL: https://github.com/apache/camel/pull/5065#discussion_r573820704



##########
File path: core/camel-support/src/main/java/org/apache/camel/converter/stream/CipherPair.java
##########
@@ -61,7 +60,18 @@ public Cipher getEncryptor() {
         return enccipher;
     }
 
-    public Cipher getDecryptor() {
-        return deccipher;
+    /**
+     * Create the decryptor every time because the decryptor is not thead safe. For example, if you reuse the decryptor
+     * instance in the Multi-cast case then you will get errors.
+     */
+    public Cipher createDecryptor() {
+        try {
+            Cipher deccipher = Cipher.getInstance(transformation);
+            deccipher.init(Cipher.DECRYPT_MODE, key, ivp == null ? null : new IvParameterSpec(ivp));
+            return deccipher;
+        } catch (GeneralSecurityException e) {
+            // should not happen
+            throw new IllegalStateException("Could not instantiate decryptor, e");

Review comment:
       What do you mean with that? Should we not catch the GeneralSecurityException?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel] davsclaus commented on a change in pull request #5065: CAMEL-16177: multicast parallel processing and encrypted stream cache

Posted by GitBox <gi...@apache.org>.
davsclaus commented on a change in pull request #5065:
URL: https://github.com/apache/camel/pull/5065#discussion_r573827160



##########
File path: core/camel-support/src/main/java/org/apache/camel/converter/stream/CipherPair.java
##########
@@ -61,7 +60,18 @@ public Cipher getEncryptor() {
         return enccipher;
     }
 
-    public Cipher getDecryptor() {
-        return deccipher;
+    /**
+     * Create the decryptor every time because the decryptor is not thead safe. For example, if you reuse the decryptor
+     * instance in the Multi-cast case then you will get errors.
+     */
+    public Cipher createDecryptor() {
+        try {
+            Cipher deccipher = Cipher.getInstance(transformation);
+            deccipher.init(Cipher.DECRYPT_MODE, key, ivp == null ? null : new IvParameterSpec(ivp));
+            return deccipher;
+        } catch (GeneralSecurityException e) {
+            // should not happen
+            throw new IllegalStateException("Could not instantiate decryptor, e");

Review comment:
       ,e is in the string text, it should be outside




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel] forsthofer commented on a change in pull request #5065: CAMEL-16177: multicast parallel processing and encrypted stream cache

Posted by GitBox <gi...@apache.org>.
forsthofer commented on a change in pull request #5065:
URL: https://github.com/apache/camel/pull/5065#discussion_r573849650



##########
File path: core/camel-support/src/main/java/org/apache/camel/converter/stream/CipherPair.java
##########
@@ -61,7 +60,18 @@ public Cipher getEncryptor() {
         return enccipher;
     }
 
-    public Cipher getDecryptor() {
-        return deccipher;
+    /**
+     * Create the decryptor every time because the decryptor is not thead safe. For example, if you reuse the decryptor
+     * instance in the Multi-cast case then you will get errors.
+     */
+    public Cipher createDecryptor() {
+        try {
+            Cipher deccipher = Cipher.getInstance(transformation);
+            deccipher.init(Cipher.DECRYPT_MODE, key, ivp == null ? null : new IvParameterSpec(ivp));
+            return deccipher;
+        } catch (GeneralSecurityException e) {
+            // should not happen
+            throw new IllegalStateException("Could not instantiate decryptor, e");

Review comment:
       o.k. I correct that




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org