Skip to content

Commit ec915bf

Browse files
committed
Avoid ClassCastException on IllegalArgumentException from sync invocation
Closes spring-projectsgh-25110
1 parent 5c04c96 commit ec915bf

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

spring-context/src/main/java/org/springframework/cache/interceptor/CacheAspectSupport.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -52,6 +52,7 @@
5252
import org.springframework.util.LinkedMultiValueMap;
5353
import org.springframework.util.MultiValueMap;
5454
import org.springframework.util.ObjectUtils;
55+
import org.springframework.util.ReflectionUtils;
5556
import org.springframework.util.StringUtils;
5657
import org.springframework.util.function.SingletonSupplier;
5758
import org.springframework.util.function.SupplierUtils;
@@ -381,9 +382,9 @@ private Object execute(final CacheOperationInvoker invoker, Method method, Cache
381382
return wrapCacheValue(method, cache.get(key, () -> unwrapReturnValue(invokeOperation(invoker))));
382383
}
383384
catch (Cache.ValueRetrievalException ex) {
384-
// The invoker wraps any Throwable in a ThrowableWrapper instance so we
385-
// can just make sure that one bubbles up the stack.
386-
throw (CacheOperationInvoker.ThrowableWrapper) ex.getCause();
385+
// Directly propagate ThrowableWrapper from the invoker,
386+
// or potentially also an IllegalArgumentException etc.
387+
ReflectionUtils.rethrowRuntimeException(ex.getCause());
387388
}
388389
}
389390
else {

0 commit comments

Comments
 (0)