From 3c49cb34806522c9962274f10f00059e29bf23cf Mon Sep 17 00:00:00 2001 From: Gary Russell Date: Thu, 22 Dec 2011 16:26:50 -0500 Subject: [PATCH] INT-2333 Mac OSX TCP Workaround on Server Side Mac OSX problem was encountered only on the client; similar code exists on the server side, so the workaround should be implemented there too; just in case. --- .../tcp/connection/TcpNioServerConnectionFactory.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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); } }