You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@orc.apache.org by GitBox <gi...@apache.org> on 2021/07/01 01:20:12 UTC

[GitHub] [orc] belugabehr commented on a change in pull request #732: ORC-827: Utilize Array copyOf

belugabehr commented on a change in pull request #732:
URL: https://github.com/apache/orc/pull/732#discussion_r661907810



##########
File path: java/core/src/java/org/apache/orc/InMemoryKeystore.java
##########
@@ -278,16 +276,7 @@ public InMemoryKeystore addKey(String keyName, int version,
       algorithm = EncryptionAlgorithm.AES_CTR_128;
     }
 
-    final byte[] buffer = new byte[algorithm.keyLength()];
-    if (algorithm.keyLength() > masterKey.length) {
-
-      System.arraycopy(masterKey, 0, buffer, 0, masterKey.length);
-      /* fill with zeros */
-      Arrays.fill(buffer, masterKey.length, buffer.length - 1, (byte) 0);
-
-    } else {
-      System.arraycopy(masterKey, 0, buffer, 0, algorithm.keyLength());
-    }

Review comment:
       As I understand this code, it's a bit superfluous.  There is no need to "fill with zeros" as the array will, by default in Java, pre-populated with zero value.
   
   And this:
   
   > For any indices that are valid in the copy but not the original, the copy will contain (byte)0. Such indices will exist if and only if the specified length is greater than that of the original array.
   
   https://docs.oracle.com/javase/7/docs/api/java/util/Arrays.html#copyOf(byte[],%20int)
   




-- 
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.

To unsubscribe, e-mail: dev-unsubscribe@orc.apache.org

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