Skip to content

Commit

Permalink
Remove Java code dependency on CoWebFilter
Browse files Browse the repository at this point in the history
To avoid compilation errors in Eclipse which does
not support Java code dependency on Kotlin code.

See spring-projectsgh-27522
  • Loading branch information
sdeleuze committed Sep 12, 2023
1 parent b6fdfe8 commit abb296c
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.reactive.BindingContext;
import org.springframework.web.reactive.HandlerResult;
import org.springframework.web.server.CoWebFilter;
import org.springframework.web.server.ServerWebExchange;

/**
Expand Down Expand Up @@ -292,13 +291,16 @@ private boolean isResponseHandled(Object[] args, ServerWebExchange exchange) {
*/
private static class KotlinDelegate {

// Copy of CoWebFilter.COROUTINE_CONTEXT_ATTRIBUTE value to avoid compilation errors in Eclipse
private static final String COROUTINE_CONTEXT_ATTRIBUTE = "org.springframework.web.server.CoWebFilter.context";

@Nullable
@SuppressWarnings("deprecation")
public static Object invokeFunction(Method method, Object target, Object[] args, boolean isSuspendingFunction,
ServerWebExchange exchange) {

if (isSuspendingFunction) {
Object coroutineContext = exchange.getAttribute(CoWebFilter.COROUTINE_CONTEXT_ATTRIBUTE);
Object coroutineContext = exchange.getAttribute(COROUTINE_CONTEXT_ATTRIBUTE);
if (coroutineContext == null) {
return CoroutinesUtils.invokeSuspendingFunction(method, target, args);
}
Expand Down

0 comments on commit abb296c

Please sign in to comment.