From b5546d1d292362f011773f5a5a4c794aa05db063 Mon Sep 17 00:00:00 2001 From: Luke Taylor Date: Wed, 15 Jun 2011 11:18:26 +0100 Subject: [PATCH] SEC-1764: Remove use of Java 6 method Arrays.copyOfRange. --- .../java/org/springframework/security/core/codec/Utf8.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/org/springframework/security/core/codec/Utf8.java b/core/src/main/java/org/springframework/security/core/codec/Utf8.java index ff1aeb8765..54dfebeb02 100644 --- a/core/src/main/java/org/springframework/security/core/codec/Utf8.java +++ b/core/src/main/java/org/springframework/security/core/codec/Utf8.java @@ -23,7 +23,9 @@ public final class Utf8 { try { ByteBuffer bytes = CHARSET.newEncoder().encode(CharBuffer.wrap(string)); - return Arrays.copyOfRange(bytes.array(), 0, bytes.limit()); + byte[] copy = new byte[bytes.limit()]; + System.arraycopy(bytes.array(), 0, copy, 0, bytes.limit()); + return copy; } catch (CharacterCodingException e) { throw new IllegalArgumentException("Encoding failed", e); }