From df1821a27953619389cdb2d4af7640ade80f288b Mon Sep 17 00:00:00 2001 From: Gary Russell Date: Thu, 22 Dec 2011 15:18:59 -0500 Subject: [PATCH] INT-2333 --- .../tcp/connection/TcpNioClientConnectionFactory.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpNioClientConnectionFactory.java b/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpNioClientConnectionFactory.java index d9306ade90..9a1095fa24 100644 --- a/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpNioClientConnectionFactory.java +++ b/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpNioClientConnectionFactory.java @@ -18,6 +18,7 @@ package org.springframework.integration.ip.tcp.connection; import java.net.InetSocketAddress; import java.nio.ByteBuffer; +import java.nio.channels.CancelledKeyException; import java.nio.channels.ClosedChannelException; import java.nio.channels.SelectionKey; import java.nio.channels.Selector; @@ -118,7 +119,15 @@ public class TcpNioClientConnectionFactory extends this.selector = Selector.open(); while (this.active) { SocketChannel newChannel; - int selectionCount = selector.select(this.soTimeout); + int soTimeout = this.getSoTimeout(); + int selectionCount = 0; + try { + selectionCount = selector.select(soTimeout < 0 ? 0 : soTimeout); + } catch (CancelledKeyException cke) { + if (logger.isDebugEnabled()) { + logger.debug("CancelledKeyException during Selector.select()"); + } + } while ((newChannel = newChannels.poll()) != null) { try { newChannel.register(this.selector, SelectionKey.OP_READ, connections.get(newChannel));