Skip to content

Commit ffe08ae

Browse files
committed
Avoid ClassCastException on IllegalArgumentException from sync invocation
Closes spring-projectsgh-25110
1 parent f4d33a6 commit ffe08ae

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.
@@ -51,6 +51,7 @@
5151
import org.springframework.util.LinkedMultiValueMap;
5252
import org.springframework.util.MultiValueMap;
5353
import org.springframework.util.ObjectUtils;
54+
import org.springframework.util.ReflectionUtils;
5455
import org.springframework.util.StringUtils;
5556

5657
/**
@@ -352,9 +353,9 @@ private Object execute(final CacheOperationInvoker invoker, Method method, Cache
352353
return wrapCacheValue(method, cache.get(key, () -> unwrapReturnValue(invokeOperation(invoker))));
353354
}
354355
catch (Cache.ValueRetrievalException ex) {
355-
// The invoker wraps any Throwable in a ThrowableWrapper instance so we
356-
// can just make sure that one bubbles up the stack.
357-
throw (CacheOperationInvoker.ThrowableWrapper) ex.getCause();
356+
// Directly propagate ThrowableWrapper from the invoker,
357+
// or potentially also an IllegalArgumentException etc.
358+
ReflectionUtils.rethrowRuntimeException(ex.getCause());
358359
}
359360
}
360361
else {

0 commit comments

Comments
 (0)