add comment in the PerMessageDeflateExtension IncomingFlusher

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
Lachlan Roberts 2023-06-15 08:27:26 +10:00
parent 81447c3e2c
commit 212ea5e6f8
1 changed files with 5 additions and 0 deletions

View File

@ -464,6 +464,11 @@ public class PerMessageDeflateExtension extends AbstractExtension implements Dem
chunk.setPayload(payload);
chunk.setFin(frame.isFin() && complete);
// If we are complete we return true, then DemandingFlusher.process() will null out the Frame and Callback.
// The application may decide to hold onto the buffer and delay completing the callback, so we need to capture
// references to these in the payloadCallback and not rely on state of the flusher which may have moved on.
// This flusher could be failed while the application already has the payloadCallback, so we need protection against
// the flusher failing and the application completing the callback, that's why we use the payload AtomicReference.
boolean completeCallback = complete;
AtomicReference<ByteBuffer> payloadRef = _payloadRef;
Callback payloadCallback = Callback.from(() ->