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

tv pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-jcs.git

commit eddb2adfe9528e75a1d9b2663c4acf2f28e3791d
Author: Thomas Vandahl <t...@apache.org>
AuthorDate: Sat Mar 27 17:45:05 2021 +0100

    Better robustness
---
 .../jcs3/auxiliary/lateral/socket/tcp/LateralTCPListener.java    | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git 
a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/socket/tcp/LateralTCPListener.java
 
b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/socket/tcp/LateralTCPListener.java
index 9b5de7b..19dafc6 100644
--- 
a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/socket/tcp/LateralTCPListener.java
+++ 
b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/socket/tcp/LateralTCPListener.java
@@ -493,10 +493,13 @@ public class LateralTCPListener<K, V>
                     continue;
                 }
 
-                Set<SelectionKey> selectedKeys = selector.selectedKeys();
-
-                for (Iterator<SelectionKey> i = selectedKeys.iterator(); 
i.hasNext();)
+                for (Iterator<SelectionKey> i = 
selector.selectedKeys().iterator(); i.hasNext();)
                 {
+                    if (terminated.get())
+                    {
+                        break;
+                    }
+
                     SelectionKey key = i.next();
 
                     if (!key.isValid())

Reply via email to