From faac5d7f04470384d5036536b806f1036fb805c2 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Thu, 10 Oct 2019 09:09:53 +1100 Subject: [PATCH] Issue #4179 SendCallback GC The HttpConnection.SendCallback nulls it's reference to buffers and callbacks after completion to assist with easy GC, since the connection callback is a long lived instance. Signed-off-by: Greg Wilkins --- .../eclipse/jetty/server/HttpConnection.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnection.java b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnection.java index 3509e3a2d53..e42223a751e 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnection.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnection.java @@ -848,19 +848,22 @@ public class HttpConnection extends AbstractConnection implements Runnable, Http } } - private void releaseHeader() + private Callback release() { - ByteBuffer h = _header; + Callback complete = _callback; + _callback = null; + _info = null; + _content = null; + if (_header != null) + _bufferPool.release(_header); _header = null; - if (h != null) - _bufferPool.release(h); + return complete; } @Override protected void onCompleteSuccess() { - releaseHeader(); - _callback.succeeded(); + release().succeeded(); if (_shutdownOut) getEndPoint().shutdownOutput(); } @@ -868,8 +871,7 @@ public class HttpConnection extends AbstractConnection implements Runnable, Http @Override public void onCompleteFailure(final Throwable x) { - releaseHeader(); - failedCallback(_callback, x); + failedCallback(release(), x); if (_shutdownOut) getEndPoint().shutdownOutput(); }