You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by se...@apache.org on 2014/07/14 15:27:40 UTC

git commit: CXF-5311 Minor optimization

Repository: cxf
Updated Branches:
  refs/heads/master 6c4aa3a94 -> 77b05b64a


CXF-5311 Minor optimization


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

Branch: refs/heads/master
Commit: 77b05b64ad9c90e638d8be70d1ef5c9e83034bbe
Parents: 6c4aa3a
Author: Sergey Beryozkin <sb...@talend.com>
Authored: Mon Jul 14 14:25:50 2014 +0100
Committer: Sergey Beryozkin <sb...@talend.com>
Committed: Mon Jul 14 14:25:50 2014 +0100

----------------------------------------------------------------------
 .../org/apache/cxf/rs/security/oauth2/jwe/JweOutputStream.java  | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/77b05b64/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwe/JweOutputStream.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwe/JweOutputStream.java b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwe/JweOutputStream.java
index 91b68b0..324ca22 100644
--- a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwe/JweOutputStream.java
+++ b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwe/JweOutputStream.java
@@ -63,8 +63,9 @@ public class JweOutputStream extends FilterOutputStream {
             }
         } 
         int offset = 0;
-        for (; offset + blockSize <= len; offset += blockSize, off += blockSize) {
-            encryptAndWrite(b, off, blockSize);
+        int chunkSize = blockSize > len ? blockSize : blockSize * (len / blockSize);
+        for (; offset + chunkSize <= len; offset += chunkSize, off += chunkSize) {
+            encryptAndWrite(b, off, chunkSize);
         }
         if (offset < len) {
             lastRawDataChunk = newArray(b, off, len - offset);