fix: allow the formbodyhandler to run tasks in the calling thread (#27642)

closes: #25687

Signed-off-by: Steve Hawkins <shawkins@redhat.com>
This commit is contained in:
Steven Hawkins 2024-03-14 09:31:33 -04:00 committed by GitHub
parent e33bf39055
commit ffd42bfdfc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -22,11 +22,8 @@ import static jakarta.ws.rs.HttpMethod.POST;
import static jakarta.ws.rs.HttpMethod.PUT;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.concurrent.Executor;
import java.util.function.Supplier;
import org.jboss.resteasy.reactive.common.model.ResourceClass;
import org.jboss.resteasy.reactive.server.handlers.FormBodyHandler;
import org.jboss.resteasy.reactive.server.model.HandlerChainCustomizer;
@ -37,14 +34,7 @@ public final class KeycloakHandlerChainCustomizer implements HandlerChainCustomi
private final CreateSessionHandler TRANSACTIONAL_SESSION_HANDLER = new CreateSessionHandler();
private final FormBodyHandler formBodyHandler = new FormBodyHandler(true, new Supplier<Executor>() {
@Override
public Executor get() {
// we always run in blocking mode and never run in an event loop thread
// we don't need to provide an executor to dispatch to a worker thread to parse the body
return null;
}
}, Set.of());
private final FormBodyHandler formBodyHandler = new FormBodyHandler(true, () -> Runnable::run, Set.of());
@Override
public List<ServerRestHandler> handlers(Phase phase, ResourceClass resourceClass,
@ -53,7 +43,7 @@ public final class KeycloakHandlerChainCustomizer implements HandlerChainCustomi
switch (phase) {
case BEFORE_METHOD_INVOKE:
if (!resourceMethod.isFormParamRequired() &&
if (!resourceMethod.isFormParamRequired() &&
(PATCH.equalsIgnoreCase(resourceMethod.getHttpMethod()) ||
POST.equalsIgnoreCase(resourceMethod.getHttpMethod()) ||
PUT.equalsIgnoreCase(resourceMethod.getHttpMethod()))) {