diff --git a/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/reactive/InvocableHandlerMethod.java b/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/reactive/InvocableHandlerMethod.java index a4370c944de..ea56427dd8f 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/reactive/InvocableHandlerMethod.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/reactive/InvocableHandlerMethod.java @@ -109,12 +109,8 @@ public class InvocableHandlerMethod extends HandlerMethod { } /** - * Configure a reactive registry. This is needed for cases where the response - * is fully handled within the controller in combination with an async void - * return value. - *

By default this is an instance of {@link ReactiveAdapterRegistry} with - * default settings. - * @param registry the registry to use + * Configure a reactive adapter registry. This is needed for async return values. + *

By default this is a {@link ReactiveAdapterRegistry} with default settings. */ public void setReactiveAdapterRegistry(ReactiveAdapterRegistry registry) { this.reactiveAdapterRegistry = registry; @@ -125,11 +121,10 @@ public class InvocableHandlerMethod extends HandlerMethod { * Invoke the method for the given exchange. * @param message the current message * @param providedArgs optional list of argument values to match by type - * @return a Mono with the result from the invocation. + * @return a Mono with the result from the invocation */ @SuppressWarnings("KotlinInternalInJava") public Mono invoke(Message message, Object... providedArgs) { - return getMethodArgumentValues(message, providedArgs).flatMap(args -> { Object value; try { @@ -157,16 +152,17 @@ public class InvocableHandlerMethod extends HandlerMethod { MethodParameter returnType = getReturnType(); ReactiveAdapter adapter = this.reactiveAdapterRegistry.getAdapter(returnType.getParameterType()); - return isAsyncVoidReturnType(returnType, adapter) ? - Mono.from(adapter.toPublisher(value)) : Mono.justOrEmpty(value); + return (isAsyncVoidReturnType(returnType, adapter) ? + Mono.from(adapter.toPublisher(value)) : Mono.justOrEmpty(value)); }); } private Mono getMethodArgumentValues(Message message, Object... providedArgs) { + MethodParameter[] parameters = getMethodParameters(); if (ObjectUtils.isEmpty(getMethodParameters())) { return EMPTY_ARGS; } - MethodParameter[] parameters = getMethodParameters(); + List> argMonos = new ArrayList<>(parameters.length); for (MethodParameter parameter : parameters) { parameter.initParameterNameDiscovery(this.parameterNameDiscoverer); @@ -196,7 +192,7 @@ public class InvocableHandlerMethod extends HandlerMethod { private void logArgumentErrorIfNecessary(MethodParameter parameter, Throwable ex) { // Leave stack trace for later, if error is not handled... String exMsg = ex.getMessage(); - if (!exMsg.contains(parameter.getExecutable().toGenericString())) { + if (exMsg != null && !exMsg.contains(parameter.getExecutable().toGenericString())) { if (logger.isDebugEnabled()) { logger.debug(formatArgumentError(parameter, exMsg)); }