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
|
* Returns a computed {@link Duration TTL expiration timeout} based on cache entry key/value if a {@link TtlFunction}
|
||||||
* if a {@link TtlFunction} was confiugred using {@link #entryTtl(TtlFunction)}.
|
* was confiugred using {@link #entryTtl(TtlFunction)}.
|
||||||
* <p>
|
* <p>
|
||||||
* Otherwise, returns the user-provided, fixed {@link Duration} if {@link #entryTtl(Duration)}
|
* Otherwise, returns the user-provided, fixed {@link Duration} if {@link #entryTtl(Duration)} was called during cache
|
||||||
* was called during cache configuration.
|
* configuration.
|
||||||
*
|
*
|
||||||
* @return the configured {@link Duration TTL expiration}.
|
* @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() {
|
public Duration getTtl() {
|
||||||
return getTtlFunction().getTimeToLive(Object.class, null);
|
return getTtlFunction().getTimeToLive(Object.class, null);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ class DefaultRedisElementReader<T> implements RedisElementReader<T> {
|
|||||||
return (T) buffer;
|
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 Christoph Strobl
|
||||||
* @author Mark Paluch
|
* @author Mark Paluch
|
||||||
* @author Guy Korland
|
* @author Guy Korland
|
||||||
|
* @author John Blum
|
||||||
* @since 1.7
|
* @since 1.7
|
||||||
*/
|
*/
|
||||||
public final class ByteUtils {
|
public final class ByteUtils {
|
||||||
@@ -251,13 +252,10 @@ public final class ByteUtils {
|
|||||||
* @param buffer must not be {@literal null}.
|
* @param buffer must not be {@literal null}.
|
||||||
* @return the extracted bytes.
|
* @return the extracted bytes.
|
||||||
* @since 2.1
|
* @since 2.1
|
||||||
|
* @deprecated Since 3.2. Use {@link #getBytes(ByteBuffer)} instead.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated(since = "3.2")
|
||||||
public static byte[] extractBytes(ByteBuffer buffer) {
|
public static byte[] extractBytes(ByteBuffer buffer) {
|
||||||
|
return getBytes(buffer);
|
||||||
ByteBuffer duplicate = buffer.duplicate();
|
|
||||||
byte[] bytes = new byte[duplicate.remaining()];
|
|
||||||
duplicate.get(bytes);
|
|
||||||
|
|
||||||
return bytes;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user