1
1
/*
2
- * Copyright 2002-2021 the original author or authors.
2
+ * Copyright 2002-2022 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -129,15 +129,16 @@ public void setReactiveAdapterRegistry(ReactiveAdapterRegistry registry) {
129
129
* @param providedArgs optional list of argument values to match by type
130
130
* @return a Mono with a {@link HandlerResult}
131
131
*/
132
- @ SuppressWarnings ("KotlinInternalInJava" )
132
+ @ SuppressWarnings ({ "KotlinInternalInJava" , "unchecked" } )
133
133
public Mono <HandlerResult > invoke (
134
134
ServerWebExchange exchange , BindingContext bindingContext , Object ... providedArgs ) {
135
135
136
136
return getMethodArgumentValues (exchange , bindingContext , providedArgs ).flatMap (args -> {
137
137
Object value ;
138
+ Method method = getBridgedMethod ();
139
+ boolean isSuspendingFunction = KotlinDetector .isSuspendingFunction (method );
138
140
try {
139
- Method method = getBridgedMethod ();
140
- if (KotlinDetector .isSuspendingFunction (method )) {
141
+ if (isSuspendingFunction ) {
141
142
value = CoroutinesUtils .invokeSuspendingFunction (method , getBean (), args );
142
143
}
143
144
else {
@@ -163,10 +164,16 @@ public Mono<HandlerResult> invoke(
163
164
}
164
165
165
166
MethodParameter returnType = getReturnType ();
166
- ReactiveAdapter adapter = this .reactiveAdapterRegistry .getAdapter (returnType .getParameterType ());
167
- boolean asyncVoid = isAsyncVoidReturnType (returnType , adapter );
168
- if ((value == null || asyncVoid ) && isResponseHandled (args , exchange )) {
169
- return (asyncVoid ? Mono .from (adapter .toPublisher (value )) : Mono .empty ());
167
+ if (isResponseHandled (args , exchange )) {
168
+ Class <?> parameterType = returnType .getParameterType ();
169
+ ReactiveAdapter adapter = this .reactiveAdapterRegistry .getAdapter (parameterType );
170
+ boolean asyncVoid = isAsyncVoidReturnType (returnType , adapter );
171
+ if (value == null || asyncVoid ) {
172
+ return (asyncVoid ? Mono .from (adapter .toPublisher (value )) : Mono .empty ());
173
+ }
174
+ if (isSuspendingFunction && parameterType == void .class ) {
175
+ return (Mono <HandlerResult >) value ;
176
+ }
170
177
}
171
178
172
179
HandlerResult result = new HandlerResult (this , value , returnType , bindingContext );
0 commit comments