Browse Source

SEC-1764: Remove use of Java 6 method Arrays.copyOfRange.

Luke Taylor 14 years ago
parent
commit
89b7b2b935

+ 3 - 1
crypto/src/main/java/org/springframework/security/crypto/codec/Utf8.java

@@ -22,8 +22,10 @@ public final class Utf8 {
     public static byte[] encode(CharSequence string) {
     public static byte[] encode(CharSequence string) {
         try {
         try {
             ByteBuffer bytes = CHARSET.newEncoder().encode(CharBuffer.wrap(string));
             ByteBuffer bytes = CHARSET.newEncoder().encode(CharBuffer.wrap(string));
+            byte[] bytesCopy = new byte[bytes.limit()];
+            System.arraycopy(bytes.array(), 0, bytesCopy, 0, bytes.limit());
 
 
-            return Arrays.copyOfRange(bytes.array(), 0, bytes.limit());
+            return bytesCopy;
         } catch (CharacterCodingException e) {
         } catch (CharacterCodingException e) {
             throw new IllegalArgumentException("Encoding failed", e);
             throw new IllegalArgumentException("Encoding failed", e);
         }
         }