Skip to content

Commit a56116f

Browse files
artembilangaryrussell
authored andcommitted
Fix package tangle in CacheRequestHandlerAdvice
1 parent 36e7041 commit a56116f

File tree

1 file changed

+25
-7
lines changed

1 file changed

+25
-7
lines changed

spring-integration-core/src/main/java/org/springframework/integration/handler/advice/CacheRequestHandlerAdvice.java

+25-7
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,17 @@
3737
import org.springframework.expression.Expression;
3838
import org.springframework.integration.expression.ExpressionUtils;
3939
import org.springframework.integration.expression.FunctionExpression;
40-
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
4140
import org.springframework.integration.support.AbstractIntegrationMessageBuilder;
4241
import org.springframework.lang.Nullable;
4342
import org.springframework.messaging.Message;
4443
import org.springframework.util.Assert;
44+
import org.springframework.util.ClassUtils;
4545
import org.springframework.util.ObjectUtils;
4646
import org.springframework.util.ReflectionUtils;
4747

4848
/**
4949
* The {@link AbstractRequestHandlerAdvice} implementation for caching
50-
* {@link AbstractReplyProducingMessageHandler.RequestHandler#handleRequestMessage(Message)} results.
50+
* {@code AbstractReplyProducingMessageHandler.RequestHandler#handleRequestMessage(Message)} results.
5151
* Supports all the cache operations - cacheable, put, evict.
5252
* By default only cacheable is applied for the provided {@code cacheNames}.
5353
* The default cache {@code key} is {@code payload} of the request message.
@@ -56,16 +56,34 @@
5656
*
5757
* @since 5.2
5858
*
59-
* @see AbstractReplyProducingMessageHandler.RequestHandler
6059
* @see CacheAspectSupport
6160
* @see CacheOperation
6261
*/
6362
public class CacheRequestHandlerAdvice extends AbstractRequestHandlerAdvice
6463
implements SmartInitializingSingleton {
6564

66-
private static final Method HANDLE_REQUEST_METHOD =
67-
ReflectionUtils.findMethod(AbstractReplyProducingMessageHandler.RequestHandler.class,
68-
"handleRequestMessage", Message.class);
65+
private static final Method HANDLE_REQUEST_METHOD;
66+
67+
static {
68+
Class<?> requestHandlerClass = null;
69+
try {
70+
requestHandlerClass = ClassUtils.forName(
71+
"org.springframework.integration.handler.AbstractReplyProducingMessageHandler.RequestHandler",
72+
null);
73+
}
74+
catch (ClassNotFoundException ex) {
75+
throw new IllegalStateException(ex);
76+
}
77+
finally {
78+
if (requestHandlerClass != null) {
79+
HANDLE_REQUEST_METHOD =
80+
ReflectionUtils.findMethod(requestHandlerClass, "handleRequestMessage", Message.class);
81+
}
82+
else {
83+
HANDLE_REQUEST_METHOD = null;
84+
}
85+
}
86+
}
6987

7088
private final IntegrationCacheAspect delegate = new IntegrationCacheAspect();
7189

@@ -91,7 +109,7 @@ public CacheRequestHandlerAdvice(String... cacheNames) {
91109

92110
/**
93111
* Configure a set of {@link CacheOperation} which are going to be applied to the
94-
* {@link AbstractReplyProducingMessageHandler.RequestHandler#handleRequestMessage(Message)}
112+
* {@code AbstractReplyProducingMessageHandler.RequestHandler#handleRequestMessage(Message)}
95113
* method via {@link IntegrationCacheAspect}.
96114
* This is similar to the technique provided by the
97115
* {@link org.springframework.cache.annotation.Caching} annotation.

0 commit comments

Comments
 (0)