diff --git a/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpNioServerConnectionFactory.java b/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpNioServerConnectionFactory.java index 806a07df5c..c561d7cf26 100644 --- a/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpNioServerConnectionFactory.java +++ b/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpNioServerConnectionFactory.java @@ -21,6 +21,7 @@ import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.Socket; import java.net.SocketException; +import java.nio.channels.CancelledKeyException; import java.nio.channels.ClosedChannelException; import java.nio.channels.SelectionKey; import java.nio.channels.Selector; @@ -114,7 +115,14 @@ public class TcpNioServerConnectionFactory extends AbstractServerConnectionFacto throws IOException, ClosedChannelException, SocketException { while (this.isActive()) { int soTimeout = this.getSoTimeout(); - int selectionCount = selector.select(soTimeout < 0 ? 0 : soTimeout); + int selectionCount = 0; + try { + selectionCount = selector.select(soTimeout < 0 ? 0 : soTimeout); + } catch (CancelledKeyException cke) { + if (logger.isDebugEnabled()) { + logger.debug("CancelledKeyException during Selector.select()"); + } + } this.processNioSelections(selectionCount, selector, server, this.connections); } }