Skip to content

Commit

Permalink
Add Coroutines support to NonReactiveHandlerMethodPredicate
Browse files Browse the repository at this point in the history
Closes gh-32227
  • Loading branch information
sdeleuze committed Feb 9, 2024
1 parent d47c697 commit 99bdc42
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
Expand Down Expand Up @@ -32,6 +32,7 @@
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.KotlinDetector;
import org.springframework.core.ReactiveAdapterRegistry;
import org.springframework.http.codec.HttpMessageReader;
import org.springframework.http.codec.ServerCodecConfigurer;
Expand Down Expand Up @@ -328,15 +329,17 @@ public Mono<HandlerResult> handleError(ServerWebExchange exchange, Throwable ex)


/**
* Match methods with a return type without an adapter in {@link ReactiveAdapterRegistry}.
* Match methods with a return type without an adapter in {@link ReactiveAdapterRegistry}
* which are not suspending functions.
*/
private record NonReactiveHandlerMethodPredicate(ReactiveAdapterRegistry adapterRegistry)
implements Predicate<HandlerMethod> {

@Override
public boolean test(HandlerMethod handlerMethod) {
Class<?> returnType = handlerMethod.getReturnType().getParameterType();
return (this.adapterRegistry.getAdapter(returnType) == null);
return (this.adapterRegistry.getAdapter(returnType) == null
&& !KotlinDetector.isSuspendingFunction(handlerMethod.getMethod()));
}
}

Expand Down

0 comments on commit 99bdc42

Please sign in to comment.