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

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

commit 6dde29123e252a9bb89fc7286665024646b7d282
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 8d6e3c6..6eddfd7 100644
--- a/java/org/apache/tomcat/util/net/Nio2Endpoint.java
+++ b/java/org/apache/tomcat/util/net/Nio2Endpoint.java
@@ -210,7 +210,10 @@ public class Nio2Endpoint extends 
AbstractJsseEndpoint<Nio2Channel> {
                     }
                 }
             });
-            nioChannels.clear();
+            Nio2Channel socket;
+            while ((socket = nioChannels.pop()) != null) {
+                socket.free();
+            }
             processorCache.clear();
         }
     }
diff --git a/java/org/apache/tomcat/util/net/NioEndpoint.java 
b/java/org/apache/tomcat/util/net/NioEndpoint.java
index 04cd5f7..0665d89 100644
--- a/java/org/apache/tomcat/util/net/NioEndpoint.java
+++ b/java/org/apache/tomcat/util/net/NioEndpoint.java
@@ -314,7 +314,10 @@ public class NioEndpoint extends 
AbstractJsseEndpoint<NioChannel> {
             }
             shutdownExecutor();
             eventCache.clear();
-            nioChannels.clear();
+            NioChannel socket;
+            while ((socket = nioChannels.pop()) != null) {
+                socket.free();
+            }
             processorCache.clear();
         }
     }
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 39c11d4..c1d3297 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -219,6 +219,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