Deprecate redundant ByteUtils.extractBytes(…) method.
Refactors extractBytes(:ByteBuffer) to call getBytes(:ByteBuffer), thereby avoid the NullPointerException by throwing the more appropriate IllegalArgumentException with a descriptive message instead. See #2733
This commit is contained in:
@@ -376,16 +376,16 @@ public class RedisCacheConfiguration {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a computed {@link Duration TTL expiration timeout} based on cache entry key/value
|
||||
* if a {@link TtlFunction} was confiugred using {@link #entryTtl(TtlFunction)}.
|
||||
* Returns a computed {@link Duration TTL expiration timeout} based on cache entry key/value if a {@link TtlFunction}
|
||||
* was confiugred using {@link #entryTtl(TtlFunction)}.
|
||||
* <p>
|
||||
* Otherwise, returns the user-provided, fixed {@link Duration} if {@link #entryTtl(Duration)}
|
||||
* was called during cache configuration.
|
||||
* Otherwise, returns the user-provided, fixed {@link Duration} if {@link #entryTtl(Duration)} was called during cache
|
||||
* configuration.
|
||||
*
|
||||
* @return the configured {@link Duration TTL expiration}.
|
||||
* @deprecated since 3.2.0. Use {@link #getTtlFunction()} instead.
|
||||
* @deprecated since 3.2. Use {@link #getTtlFunction()} instead.
|
||||
*/
|
||||
@Deprecated(since = "3.2.0")
|
||||
@Deprecated(since = "3.2")
|
||||
public Duration getTtl() {
|
||||
return getTtlFunction().getTimeToLive(Object.class, null);
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ class DefaultRedisElementReader<T> implements RedisElementReader<T> {
|
||||
return (T) buffer;
|
||||
}
|
||||
|
||||
return serializer.deserialize(ByteUtils.extractBytes(buffer));
|
||||
return serializer.deserialize(ByteUtils.getBytes(buffer));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ import org.springframework.util.ObjectUtils;
|
||||
* @author Christoph Strobl
|
||||
* @author Mark Paluch
|
||||
* @author Guy Korland
|
||||
* @author John Blum
|
||||
* @since 1.7
|
||||
*/
|
||||
public final class ByteUtils {
|
||||
@@ -251,13 +252,10 @@ public final class ByteUtils {
|
||||
* @param buffer must not be {@literal null}.
|
||||
* @return the extracted bytes.
|
||||
* @since 2.1
|
||||
* @deprecated Since 3.2. Use {@link #getBytes(ByteBuffer)} instead.
|
||||
*/
|
||||
@Deprecated(since = "3.2")
|
||||
public static byte[] extractBytes(ByteBuffer buffer) {
|
||||
|
||||
ByteBuffer duplicate = buffer.duplicate();
|
||||
byte[] bytes = new byte[duplicate.remaining()];
|
||||
duplicate.get(bytes);
|
||||
|
||||
return bytes;
|
||||
return getBytes(buffer);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user