From 1a10be7c76aa002ac4cf3c24e9cad37f8680a773 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Mon, 22 May 2023 16:13:49 -0500 Subject: [PATCH] Issue #8885 - Restore HttpChannel.Listener --- .../eclipse/jetty/server/internal/HttpChannelState.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/internal/HttpChannelState.java b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/internal/HttpChannelState.java index 7c3c02c32ccd..73c14c076f7a 100644 --- a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/internal/HttpChannelState.java +++ b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/internal/HttpChannelState.java @@ -1168,9 +1168,10 @@ else if (contentLength >= 0) else if (failure != null) { Throwable throwable = failure; + ByteBuffer slice = content != null ? content.slice() : BufferUtil.EMPTY_BUFFER; httpChannelState._serializedInvoker.run(() -> { - _listener.onResponseWrite(_request, last, content.slice(), throwable); + _listener.onResponseWrite(_request, last, slice, throwable); callback.failed(throwable); }); } @@ -1192,10 +1193,10 @@ else if (failure != null) { if (LOG.isDebugEnabled()) LOG.debug("writing last={} {} {}", last, BufferUtil.toDetailString(content), this); - ByteBuffer contentSlice = content.slice(); + ByteBuffer slice = content != null ? content.slice() : BufferUtil.EMPTY_BUFFER; Callback listenerCallback = Callback.from(() -> { - _listener.onResponseWrite(_request, last, contentSlice, null); + _listener.onResponseWrite(_request, last, slice, null); }, this); stream.send(_request._metaData, responseMetaData, last, content, listenerCallback); }