From 9c73023e5a1e9ad2f0617a4cf7679df6f8254a0c Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 10 Jun 2020 12:16:19 +0200 Subject: [PATCH] Avoid ClassCastException on IllegalArgumentException from sync invocation Closes gh-25223 --- .../cache/interceptor/CacheAspectSupport.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/spring-context/src/main/java/org/springframework/cache/interceptor/CacheAspectSupport.java b/spring-context/src/main/java/org/springframework/cache/interceptor/CacheAspectSupport.java index 9278bb10f6d8..adf7aff82f7d 100644 --- a/spring-context/src/main/java/org/springframework/cache/interceptor/CacheAspectSupport.java +++ b/spring-context/src/main/java/org/springframework/cache/interceptor/CacheAspectSupport.java @@ -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. @@ -50,6 +50,7 @@ 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; /** @@ -365,9 +366,9 @@ public Object call() throws Exception { })); } 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 {