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

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

commit a30a708b7eefa9dbef2771f7848d642a1a038550
Author: Thomas Vandahl <[email protected]>
AuthorDate: Sat Apr 6 18:52:38 2024 +0200

    Shorter handling loop
---
 .../commons/jcs3/auxiliary/lateral/socket/tcp/LateralTCPListener.java  | 3 +--
 .../org/apache/commons/jcs3/utils/discovery/UDPDiscoveryReceiver.java  | 3 +--
 2 files changed, 2 insertions(+), 4 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 fc6f92e9..0d96ca37 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
@@ -537,6 +537,7 @@ public class LateralTCPListener<K, V>
                     }
 
                     SelectionKey key = i.next();
+                    i.remove();
 
                     if (!key.isValid())
                     {
@@ -563,8 +564,6 @@ public class LateralTCPListener<K, V>
                     {
                         handleClient(key);
                     }
-
-                    i.remove();
                 }
             }
 
diff --git 
a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/utils/discovery/UDPDiscoveryReceiver.java
 
b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/utils/discovery/UDPDiscoveryReceiver.java
index 573197e9..1cd36de5 100644
--- 
a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/utils/discovery/UDPDiscoveryReceiver.java
+++ 
b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/utils/discovery/UDPDiscoveryReceiver.java
@@ -237,6 +237,7 @@ public class UDPDiscoveryReceiver
                     }
 
                     SelectionKey key = i.next();
+                    i.remove();
 
                     if (!key.isValid())
                     {
@@ -294,8 +295,6 @@ public class UDPDiscoveryReceiver
                         {
                             log.error( "Error receiving multicast packet", e );
                         }
-
-                        i.remove();
                     }
                 }
             } // end while

Reply via email to