mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-29 02:39:04 +00:00
Detect custom deserialized NullValue instances
Closes gh-36727
(cherry picked from commit 916cb64581)
This commit is contained in:
Vendored
+1
-1
@@ -87,7 +87,7 @@ public abstract class AbstractValueAdaptingCache implements Cache {
|
||||
*/
|
||||
@Nullable
|
||||
protected Object fromStoreValue(@Nullable Object storeValue) {
|
||||
if (this.allowNullValues && storeValue == NullValue.INSTANCE) {
|
||||
if (this.allowNullValues && storeValue instanceof NullValue) {
|
||||
return null;
|
||||
}
|
||||
return storeValue;
|
||||
|
||||
+8
@@ -24,7 +24,9 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.cache.Cache;
|
||||
import org.springframework.cache.support.NullValue;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@@ -72,6 +74,12 @@ public abstract class AbstractCacheTests<T extends Cache> {
|
||||
assertThat(cache.get(key).get()).isNull();
|
||||
assertThat(cache.get(key, String.class)).isNull();
|
||||
assertThat(cache.get(key, Object.class)).isNull();
|
||||
|
||||
cache.put(key, BeanUtils.instantiateClass(NullValue.class));
|
||||
assertThat(cache.get(key)).isNotNull();
|
||||
assertThat(cache.get(key).get()).isNull();
|
||||
assertThat(cache.get(key, String.class)).isNull();
|
||||
assertThat(cache.get(key, Object.class)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user