Merge branch '5.2.x'
# Conflicts: # spring-jdbc/src/test/java/org/springframework/jdbc/core/JdbcTemplateQueryTests.java # spring-jdbc/src/test/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcTemplateTests.java
This commit is contained in:
@@ -16,9 +16,6 @@
|
||||
|
||||
package org.springframework.cache.concurrent;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
@@ -45,6 +42,7 @@ import org.springframework.util.Assert;
|
||||
* @author Juergen Hoeller
|
||||
* @author Stephane Nicoll
|
||||
* @since 3.1
|
||||
* @see ConcurrentMapCacheManager
|
||||
*/
|
||||
public class ConcurrentMapCache extends AbstractValueAdaptingCache {
|
||||
|
||||
@@ -190,7 +188,7 @@ public class ConcurrentMapCache extends AbstractValueAdaptingCache {
|
||||
Object storeValue = super.toStoreValue(userValue);
|
||||
if (this.serialization != null) {
|
||||
try {
|
||||
return serializeValue(this.serialization, storeValue);
|
||||
return this.serialization.serializeToByteArray(storeValue);
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
throw new IllegalArgumentException("Failed to serialize cache value '" + userValue +
|
||||
@@ -202,17 +200,11 @@ public class ConcurrentMapCache extends AbstractValueAdaptingCache {
|
||||
}
|
||||
}
|
||||
|
||||
private static Object serializeValue(SerializationDelegate serialization, Object storeValue) throws IOException {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
serialization.serialize(storeValue, out);
|
||||
return out.toByteArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object fromStoreValue(@Nullable Object storeValue) {
|
||||
if (storeValue != null && this.serialization != null) {
|
||||
try {
|
||||
return super.fromStoreValue(deserializeValue(this.serialization, storeValue));
|
||||
return super.fromStoreValue(this.serialization.deserializeFromByteArray((byte[]) storeValue));
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
throw new IllegalArgumentException("Failed to deserialize cache value '" + storeValue + "'", ex);
|
||||
@@ -221,12 +213,6 @@ public class ConcurrentMapCache extends AbstractValueAdaptingCache {
|
||||
else {
|
||||
return super.fromStoreValue(storeValue);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static Object deserializeValue(SerializationDelegate serialization, Object storeValue) throws IOException {
|
||||
ByteArrayInputStream in = new ByteArrayInputStream((byte[]) storeValue);
|
||||
return serialization.deserialize(in);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -190,9 +190,7 @@ public class ConcurrentMapCacheManager implements CacheManager, BeanClassLoaderA
|
||||
*/
|
||||
protected Cache createConcurrentMapCache(String name) {
|
||||
SerializationDelegate actualSerialization = (isStoreByValue() ? this.serialization : null);
|
||||
return new ConcurrentMapCache(name, new ConcurrentHashMap<>(256),
|
||||
isAllowNullValues(), actualSerialization);
|
||||
|
||||
return new ConcurrentMapCache(name, new ConcurrentHashMap<>(256), isAllowNullValues(), actualSerialization);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -52,6 +52,7 @@ import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.util.function.SingletonSupplier;
|
||||
import org.springframework.util.function.SupplierUtils;
|
||||
@@ -382,9 +383,9 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
|
||||
return wrapCacheValue(method, cache.get(key, () -> unwrapReturnValue(invokeOperation(invoker))));
|
||||
}
|
||||
catch (Cache.ValueRetrievalException ex) {
|
||||
// The invoker wraps any Throwable in a ThrowableWrapper instance so we
|
||||
// can just make sure that one bubbles up the stack.
|
||||
throw (CacheOperationInvoker.ThrowableWrapper) ex.getCause();
|
||||
// Directly propagate ThrowableWrapper from the invoker,
|
||||
// or potentially also an IllegalArgumentException etc.
|
||||
ReflectionUtils.rethrowRuntimeException(ex.getCause());
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -30,6 +30,7 @@ import org.springframework.util.Assert;
|
||||
* @author Costin Leau
|
||||
* @author Stephane Nicoll
|
||||
* @since 4.3.4
|
||||
* @see NoOpCacheManager
|
||||
*/
|
||||
public class NoOpCache implements Cache {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -37,7 +37,7 @@ import org.springframework.lang.Nullable;
|
||||
* @author Costin Leau
|
||||
* @author Stephane Nicoll
|
||||
* @since 3.1
|
||||
* @see CompositeCacheManager
|
||||
* @see NoOpCache
|
||||
*/
|
||||
public class NoOpCacheManager implements CacheManager {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user