This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 6f8482d14d0fa59e40bb889aa5b0d2aa5a503660
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Mon Jan 10 17:45:07 2022 +0000

    Explicitly release pooled ByteBuffer instances on endpoint stop
---
 java/org/apache/tomcat/util/net/Nio2Endpoint.java | 5 ++++-
 java/org/apache/tomcat/util/net/NioEndpoint.java  | 5 ++++-
 webapps/docs/changelog.xml                        | 4 ++++
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/tomcat/util/net/Nio2Endpoint.java 
b/java/org/apache/tomcat/util/net/Nio2Endpoint.java
index 0ecac93..0f6d8a0 100644
--- a/java/org/apache/tomcat/util/net/Nio2Endpoint.java
+++ b/java/org/apache/tomcat/util/net/Nio2Endpoint.java
@@ -220,7 +220,10 @@ public class Nio2Endpoint extends 
AbstractJsseEndpoint<Nio2Channel,AsynchronousS
                 }
             });
             if (nioChannels != null) {
-                nioChannels.clear();
+                Nio2Channel socket;
+                while ((socket = nioChannels.pop()) != null) {
+                    socket.free();
+                }
                 nioChannels = null;
             }
             if (processorCache != null) {
diff --git a/java/org/apache/tomcat/util/net/NioEndpoint.java 
b/java/org/apache/tomcat/util/net/NioEndpoint.java
index b5b0e50..66b6636 100644
--- a/java/org/apache/tomcat/util/net/NioEndpoint.java
+++ b/java/org/apache/tomcat/util/net/NioEndpoint.java
@@ -346,7 +346,10 @@ public class NioEndpoint extends 
AbstractJsseEndpoint<NioChannel,SocketChannel>
                 eventCache = null;
             }
             if (nioChannels != null) {
-                nioChannels.clear();
+                NioChannel socket;
+                while ((socket = nioChannels.pop()) != null) {
+                    socket.free();
+                }
                 nioChannels = null;
             }
             if (processorCache != null) {
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 26aeced..707ec40 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -163,6 +163,10 @@
         and new requests on existing connections are stopped while allowing in
         progress requests to run to completion. (markt)
       </fix>
+      <fix>
+        Explicitly release ByteBuffer instances associated with pooled channels
+        when stopping the NioEndpoint and Nio2Endpoint. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Jasper">

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to