-
Bug
-
Resolution: Unresolved
-
Minor
-
None
-
2.3.18.Final
-
None
Under certain conditions - for example, with a large payload or when buffer reuse is forced by client behavior - HttpServerExchange.getRequestReceiver().receiveFullBytes(...) performs the actual async buffer read and, importantly, invokes the read-body callback on the I/O thread which prematurely unlocks the dispatch(...), so the handler returns before the request is fully processed.
public void handle(HttpServerExchange exchange) throws Exception { exchange.dispatch(() -> { // ... exchange.getRequestReceiver().receiveFullBytes((ex, messageBytes) -> { // ...async work here, which needs to // be dispatched again since execution // might be in the I/O thread. // This is not obvious, because it's // not documented and not consistently reproducible. }); }); }
I’ve put it as Minor, since I’m not sure whether this is a bug or undocumented behavior – but it was painful to figure out, so at the very least it would be better if this was clearly documented.