Skip to content

Commit 64cd30d

Browse files
committed
Deprecate redundant extractBytes(:ByteBuffer) method in ByteUtils.
Refactors extractBytes(:ByteBuffer) to call getBytes(:ByteBuffer), thereby avoid the NullPointerException by throwing the more appropriate IllegalArgumentException with a descriptive message instead.
1 parent 72b57d2 commit 64cd30d

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/main/java/org/springframework/data/redis/util/ByteUtils.java

+4-6
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
* @author Christoph Strobl
3232
* @author Mark Paluch
3333
* @author Guy Korland
34+
* @author John Blum
3435
* @since 1.7
3536
*/
3637
public final class ByteUtils {
@@ -251,13 +252,10 @@ public static ByteBuffer getByteBuffer(String theString, Charset charset) {
251252
* @param buffer must not be {@literal null}.
252253
* @return the extracted bytes.
253254
* @since 2.1
255+
* @deprecated Since 3.2.0. Use {@link #getBytes(ByteBuffer)} instead.
254256
*/
257+
@Deprecated(since = "3.2.0")
255258
public static byte[] extractBytes(ByteBuffer buffer) {
256-
257-
ByteBuffer duplicate = buffer.duplicate();
258-
byte[] bytes = new byte[duplicate.remaining()];
259-
duplicate.get(bytes);
260-
261-
return bytes;
259+
return getBytes(buffer);
262260
}
263261
}

0 commit comments

Comments
 (0)