Skip to content

Commit 9c73023

Browse files
committed
Avoid ClassCastException on IllegalArgumentException from sync invocation
Closes gh-25223
1 parent 700fede commit 9c73023

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.
@@ -50,6 +50,7 @@
5050
import org.springframework.util.LinkedMultiValueMap;
5151
import org.springframework.util.MultiValueMap;
5252
import org.springframework.util.ObjectUtils;
53+
import org.springframework.util.ReflectionUtils;
5354
import org.springframework.util.StringUtils;
5455

5556
/**
@@ -365,9 +366,9 @@ public Object call() throws Exception {
365366
}));
366367
}
367368
catch (Cache.ValueRetrievalException ex) {
368-
// The invoker wraps any Throwable in a ThrowableWrapper instance so we
369-
// can just make sure that one bubbles up the stack.
370-
throw (CacheOperationInvoker.ThrowableWrapper) ex.getCause();
369+
// Directly propagate ThrowableWrapper from the invoker,
370+
// or potentially also an IllegalArgumentException etc.
371+
ReflectionUtils.rethrowRuntimeException(ex.getCause());
371372
}
372373
}
373374
else {

0 commit comments

Comments
 (0)