8686public class SimpAnnotationMethodMessageHandler extends AbstractMethodMessageHandler <SimpMessageMappingInfo >
8787 implements EmbeddedValueResolverAware , SmartLifecycle {
8888
89- private static final boolean completableFuturePresent = ClassUtils .isPresent ("java.util.concurrent.CompletableFuture" ,
90- SimpAnnotationMethodMessageHandler .class .getClassLoader ());
89+ private static final boolean completableFuturePresent = ClassUtils .isPresent (
90+ "java.util.concurrent.CompletableFuture" , SimpAnnotationMethodMessageHandler .class .getClassLoader ());
9191
9292
9393 private final SubscribableChannel clientInboundChannel ;
@@ -304,9 +304,8 @@ public final void stop(Runnable callback) {
304304
305305
306306 protected List <HandlerMethodArgumentResolver > initArgumentResolvers () {
307- ConfigurableBeanFactory beanFactory =
308- (ClassUtils .isAssignableValue (ConfigurableApplicationContext .class , getApplicationContext ())) ?
309- ((ConfigurableApplicationContext ) getApplicationContext ()).getBeanFactory () : null ;
307+ ConfigurableBeanFactory beanFactory = (getApplicationContext () instanceof ConfigurableApplicationContext ?
308+ ((ConfigurableApplicationContext ) getApplicationContext ()).getBeanFactory () : null );
310309
311310 List <HandlerMethodArgumentResolver > resolvers = new ArrayList <HandlerMethodArgumentResolver >();
312311
@@ -327,7 +326,6 @@ protected List<HandlerMethodArgumentResolver> initArgumentResolvers() {
327326
328327 @ Override
329328 protected List <? extends HandlerMethodReturnValueHandler > initReturnValueHandlers () {
330-
331329 List <HandlerMethodReturnValueHandler > handlers = new ArrayList <HandlerMethodReturnValueHandler >();
332330
333331 // Single-purpose return value types
@@ -337,11 +335,13 @@ protected List<? extends HandlerMethodReturnValueHandler> initReturnValueHandler
337335 }
338336
339337 // Annotation-based return value types
340- SendToMethodReturnValueHandler sth = new SendToMethodReturnValueHandler (this .brokerTemplate , true );
338+ SendToMethodReturnValueHandler sth =
339+ new SendToMethodReturnValueHandler (this .brokerTemplate , true );
341340 sth .setHeaderInitializer (this .headerInitializer );
342341 handlers .add (sth );
343342
344- SubscriptionMethodReturnValueHandler sh = new SubscriptionMethodReturnValueHandler (this .clientMessagingTemplate );
343+ SubscriptionMethodReturnValueHandler sh =
344+ new SubscriptionMethodReturnValueHandler (this .clientMessagingTemplate );
345345 sh .setHeaderInitializer (this .headerInitializer );
346346 handlers .add (sh );
347347
@@ -468,13 +468,15 @@ public int compare(SimpMessageMappingInfo info1, SimpMessageMappingInfo info2) {
468468 protected void handleMatch (SimpMessageMappingInfo mapping , HandlerMethod handlerMethod ,
469469 String lookupDestination , Message <?> message ) {
470470
471- String matchedPattern = mapping .getDestinationConditions ().getPatterns ().iterator ().next ();
472- Map <String , String > vars = getPathMatcher ().extractUriTemplateVariables (matchedPattern , lookupDestination );
473-
474- if (!CollectionUtils .isEmpty (vars )) {
475- MessageHeaderAccessor accessor = MessageHeaderAccessor .getAccessor (message , MessageHeaderAccessor .class );
476- Assert .state (accessor != null && accessor .isMutable ());
477- accessor .setHeader (DestinationVariableMethodArgumentResolver .DESTINATION_TEMPLATE_VARIABLES_HEADER , vars );
471+ Set <String > patterns = mapping .getDestinationConditions ().getPatterns ();
472+ if (!CollectionUtils .isEmpty (patterns )) {
473+ String pattern = patterns .iterator ().next ();
474+ Map <String , String > vars = getPathMatcher ().extractUriTemplateVariables (pattern , lookupDestination );
475+ if (!CollectionUtils .isEmpty (vars )) {
476+ MessageHeaderAccessor mha = MessageHeaderAccessor .getAccessor (message , MessageHeaderAccessor .class );
477+ Assert .state (mha != null && mha .isMutable ());
478+ mha .setHeader (DestinationVariableMethodArgumentResolver .DESTINATION_TEMPLATE_VARIABLES_HEADER , vars );
479+ }
478480 }
479481
480482 try {
0 commit comments