This is an automated email from the ASF dual-hosted git repository. lihan pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push: new 2cb6f8e468 Clear SocketWrapper reference to help GC 2cb6f8e468 is described below commit 2cb6f8e4681359087a2a52b6950a315383a8d422 Author: lihan <li...@apache.org> AuthorDate: Fri May 19 11:24:27 2023 +0800 Clear SocketWrapper reference to help GC (cherry picked from commit 10492dd22bd64ff63cf77786fa67d45cdc2a54b3) --- java/org/apache/coyote/AbstractProcessor.java | 3 +++ java/org/apache/coyote/http11/Http11Processor.java | 1 - java/org/apache/coyote/http2/StreamProcessor.java | 6 +----- java/org/apache/tomcat/util/net/Nio2Channel.java | 1 + java/org/apache/tomcat/util/net/NioChannel.java | 1 + 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/java/org/apache/coyote/AbstractProcessor.java b/java/org/apache/coyote/AbstractProcessor.java index a49bc921cf..0230a5d442 100644 --- a/java/org/apache/coyote/AbstractProcessor.java +++ b/java/org/apache/coyote/AbstractProcessor.java @@ -716,6 +716,9 @@ public abstract class AbstractProcessor extends AbstractProcessorLight implement public void recycle() { errorState = ErrorState.NONE; asyncStateMachine.recycle(); + // Clear fields that can be cleared to aid GC and trigger NPEs if this + // is reused + socketWrapper = null; } diff --git a/java/org/apache/coyote/http11/Http11Processor.java b/java/org/apache/coyote/http11/Http11Processor.java index aab2290407..9070b9727c 100644 --- a/java/org/apache/coyote/http11/Http11Processor.java +++ b/java/org/apache/coyote/http11/Http11Processor.java @@ -1419,7 +1419,6 @@ public class Http11Processor extends AbstractProcessor { inputBuffer.recycle(); outputBuffer.recycle(); upgradeToken = null; - socketWrapper = null; sendfileData = null; sslSupport = null; } diff --git a/java/org/apache/coyote/http2/StreamProcessor.java b/java/org/apache/coyote/http2/StreamProcessor.java index fd1e011bea..e1ed635e8d 100644 --- a/java/org/apache/coyote/http2/StreamProcessor.java +++ b/java/org/apache/coyote/http2/StreamProcessor.java @@ -391,8 +391,8 @@ class StreamProcessor extends AbstractProcessor { @Override public final void recycle() { + super.recycle(); // StreamProcessor instances are not re-used. - // Calling removeRequestProcessor even though the RequestProcesser was // never added will add the values from the RequestProcessor to the // running total for the GlobalRequestProcessor @@ -400,10 +400,6 @@ class StreamProcessor extends AbstractProcessor { if (global != null) { global.removeRequestProcessor(request.getRequestProcessor()); } - - // Clear fields that can be cleared to aid GC and trigger NPEs if this - // is reused - setSocketWrapper(null); } diff --git a/java/org/apache/tomcat/util/net/Nio2Channel.java b/java/org/apache/tomcat/util/net/Nio2Channel.java index a2612fd0c1..6040b8855e 100644 --- a/java/org/apache/tomcat/util/net/Nio2Channel.java +++ b/java/org/apache/tomcat/util/net/Nio2Channel.java @@ -79,6 +79,7 @@ public class Nio2Channel implements AsynchronousByteChannel { @Override public void close() throws IOException { sc.close(); + reset(this.sc, null); } diff --git a/java/org/apache/tomcat/util/net/NioChannel.java b/java/org/apache/tomcat/util/net/NioChannel.java index 8e3cb4f0e1..777880d67d 100644 --- a/java/org/apache/tomcat/util/net/NioChannel.java +++ b/java/org/apache/tomcat/util/net/NioChannel.java @@ -99,6 +99,7 @@ public class NioChannel implements ByteChannel, ScatteringByteChannel, Gathering @Override public void close() throws IOException { sc.close(); + reset(this.sc,null); } /** --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org