Upgrade to Undertow 2.3.18.Final, dispatch in UndertowHttpHandlerAdapter
This ensures that the reactive handling of the request is dispatched from the Undertow IO thread, marking the exchange as async rather than ending it once the Undertow `handleRequest` method returns. Closes gh-33885
This commit is contained in:
@@ -66,25 +66,27 @@ public class UndertowHttpHandlerAdapter implements io.undertow.server.HttpHandle
|
||||
|
||||
@Override
|
||||
public void handleRequest(HttpServerExchange exchange) {
|
||||
UndertowServerHttpRequest request = null;
|
||||
try {
|
||||
request = new UndertowServerHttpRequest(exchange, getDataBufferFactory());
|
||||
}
|
||||
catch (URISyntaxException ex) {
|
||||
if (logger.isWarnEnabled()) {
|
||||
logger.debug("Failed to get request URI: " + ex.getMessage());
|
||||
exchange.dispatch(() -> {
|
||||
UndertowServerHttpRequest request = null;
|
||||
try {
|
||||
request = new UndertowServerHttpRequest(exchange, getDataBufferFactory());
|
||||
}
|
||||
exchange.setStatusCode(400);
|
||||
return;
|
||||
}
|
||||
ServerHttpResponse response = new UndertowServerHttpResponse(exchange, getDataBufferFactory(), request);
|
||||
catch (URISyntaxException ex) {
|
||||
if (logger.isWarnEnabled()) {
|
||||
logger.debug("Failed to get request URI: " + ex.getMessage());
|
||||
}
|
||||
exchange.setStatusCode(400);
|
||||
return;
|
||||
}
|
||||
ServerHttpResponse response = new UndertowServerHttpResponse(exchange, getDataBufferFactory(), request);
|
||||
|
||||
if (request.getMethod() == HttpMethod.HEAD) {
|
||||
response = new HttpHeadResponseDecorator(response);
|
||||
}
|
||||
if (request.getMethod() == HttpMethod.HEAD) {
|
||||
response = new HttpHeadResponseDecorator(response);
|
||||
}
|
||||
|
||||
HandlerResultSubscriber resultSubscriber = new HandlerResultSubscriber(exchange, request);
|
||||
this.httpHandler.handle(request, response).subscribe(resultSubscriber);
|
||||
HandlerResultSubscriber resultSubscriber = new HandlerResultSubscriber(exchange, request);
|
||||
this.httpHandler.handle(request, response).subscribe(resultSubscriber);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user