[grizzly~git:b7b87847] [master] + fix the issue #1587

  • From: oleksiys@...
  • To: commits@...
  • Subject: [grizzly~git:b7b87847] [master] + fix the issue #1587
  • Date: Tue, 17 Sep 2013 23:32:57 +0000

Project:    grizzly
Repository: git
Revision:   b7b87847d215518a7c01f4dc44aee0244299d481
Author:     oleksiys
Date:       2013-09-17 23:30:06 UTC
Link:       

Log Message:
------------
[master] + fix the issue #1587
https://java.net/jira/browse/GRIZZLY-1587

"ConnectionPool's keep-alive/reconnect management thread is not getting 
stopped"



Revisions:
----------
b7b87847d215518a7c01f4dc44aee0244299d481


Modified Paths:
---------------
extras/connection-pool/src/main/java/org/glassfish/grizzly/connectionpool/MultiEndpointPool.java
extras/connection-pool/src/main/java/org/glassfish/grizzly/connectionpool/SingleEndpointPool.java


Diffs:
------
--- 
a/extras/connection-pool/src/main/java/org/glassfish/grizzly/connectionpool/MultiEndpointPool.java
+++ 
b/extras/connection-pool/src/main/java/org/glassfish/grizzly/connectionpool/MultiEndpointPool.java
@@ -41,6 +41,7 @@ package org.glassfish.grizzly.connectionpool;
 
 import java.io.IOException;
 import java.util.Map;
+import java.util.concurrent.ExecutorService;
 import java.util.concurrent.TimeUnit;
 import java.util.logging.Level;
 import java.util.logging.Logger;
@@ -131,6 +132,10 @@ public class MultiEndpointPool<E> {
             new Chain<EndpointPoolImpl>();
     
     /**
+     * The thread-pool used by theownDelayedExecutor
+     */
+    private final ExecutorService ownDelayedExecutorThreadPool;
+    /**
      * Own/internal {@link DelayedExecutor} to be used for keep-alive and 
reconnect
      * mechanisms, if one (DelayedExecutor} was not specified by user
      */
@@ -228,11 +233,15 @@ public class MultiEndpointPool<E> {
                     .setCorePoolSize(1)
                     .setMaxPoolSize(1);
 
+            ownDelayedExecutorThreadPool =
+                    GrizzlyExecutorService.createInstance(tpc);
             ownDelayedExecutor = new DelayedExecutor(
-                    GrizzlyExecutorService.createInstance(tpc));
+                    ownDelayedExecutorThreadPool);
             ownDelayedExecutor.start();
+            
             delayedExecutor = ownDelayedExecutor;
         } else {
+            ownDelayedExecutorThreadPool = null;
             ownDelayedExecutor = null;
         }
         
@@ -539,6 +548,10 @@ public class MultiEndpointPool<E> {
             if (ownDelayedExecutor != null) {
                 ownDelayedExecutor.destroy();
             }
+            
+            if (ownDelayedExecutorThreadPool != null) {
+                ownDelayedExecutorThreadPool.shutdownNow();
+            }            
         }
     }
 --- 
a/extras/connection-pool/src/main/java/org/glassfish/grizzly/connectionpool/SingleEndpointPool.java
+++ 
b/extras/connection-pool/src/main/java/org/glassfish/grizzly/connectionpool/SingleEndpointPool.java
@@ -44,6 +44,7 @@ import java.net.ConnectException;
 import java.net.SocketAddress;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.concurrent.ExecutorService;
 import java.util.concurrent.TimeUnit;
 import java.util.logging.Level;
 import java.util.logging.Logger;
@@ -137,11 +138,14 @@ public class SingleEndpointPool<E> {
     private boolean isClosed;
     
     /**
+     * The thread-pool used by theownDelayedExecutor
+     */
+    private final ExecutorService ownDelayedExecutorThreadPool;
+    /**
      * Own/internal {@link DelayedExecutor} to be used for keep-alive and 
reconnect
      * mechanisms, if one (DelayedExecutor} was not specified by user
      */
     private final DelayedExecutor ownDelayedExecutor;
-    
     /**
      * DelayQueue for connect timeout mechanism
      */
@@ -266,13 +270,16 @@ public class SingleEndpointPool<E> {
                     .setPoolName("connection-pool-delays-thread-pool")
                     .setCorePoolSize(1)
                     .setMaxPoolSize(1);
-
+            
+            ownDelayedExecutorThreadPool =
+                    GrizzlyExecutorService.createInstance(tpc);
             ownDelayedExecutor = new DelayedExecutor(
-                    GrizzlyExecutorService.createInstance(tpc));
+                    ownDelayedExecutorThreadPool);
             ownDelayedExecutor.start();
             
             delayedExecutor = ownDelayedExecutor;
         } else {
+            ownDelayedExecutorThreadPool = null;
             ownDelayedExecutor = null;
         }
         
@@ -345,6 +352,7 @@ public class SingleEndpointPool<E> {
         this.keepAliveCheckIntervalMillis = keepAliveCheckIntervalMillis;
         this.maxReconnectAttempts = maxReconnectAttempts;
         ownDelayedExecutor = null;
+        ownDelayedExecutorThreadPool = null;
         
         this.connectTimeoutQueue = connectTimeoutQueue;
         this.reconnectQueue = reconnectQueue;
@@ -698,6 +706,10 @@ public class SingleEndpointPool<E> {
                     ownDelayedExecutor.destroy();
                 }
                 
+                if (ownDelayedExecutorThreadPool != null) {
+                    ownDelayedExecutorThreadPool.shutdownNow();
+                }
+                
                 final int size = readyConnections.size();
                 for (int i = 0; i < size; i++) {
                     final Connection c = 
readyConnections.pollLast().getValue().connection;





[grizzly~git:b7b87847] [master] + fix the issue #1587

oleksiys 09/17/2013
Terms of Use; Privacy Policy; Copyright ©2013-2017 (revision 20160708.bf2ac18)
 
 
Close
loading
Please Confirm
Close