From 9b8150a7328d059506d6398560e87ce7a8b50c5b Mon Sep 17 00:00:00 2001 From: Gary Russell Date: Sat, 6 Mar 2010 23:49:14 +0000 Subject: [PATCH] Fix remaining TODOs --- .../integration/ip/tcp/NioSocketWriter.java | 2 -- .../ip/tcp/TcpNetReceivingChannelAdapter.java | 21 ++++++++--------- .../ip/tcp/TcpNetSendingMessageHandler.java | 3 +-- .../ip/tcp/TcpNioReceivingChannelAdapter.java | 23 ++++++++----------- .../ip/tcp/TcpNioSendingMessageHandler.java | 3 +-- .../ip/udp/UdpMulticastEndToEndTests.java | 1 - 6 files changed, 21 insertions(+), 32 deletions(-) diff --git a/org.springframework.integration.ip/src/main/java/org/springframework/integration/ip/tcp/NioSocketWriter.java b/org.springframework.integration.ip/src/main/java/org/springframework/integration/ip/tcp/NioSocketWriter.java index 4445cfa112..03b9594aea 100644 --- a/org.springframework.integration.ip/src/main/java/org/springframework/integration/ip/tcp/NioSocketWriter.java +++ b/org.springframework.integration.ip/src/main/java/org/springframework/integration/ip/tcp/NioSocketWriter.java @@ -104,8 +104,6 @@ public class NioSocketWriter extends AbstractSocketWriter { */ @Override protected void writeCustomFormat(byte[] bytes) throws IOException { - // TODO Auto-generated method stub - } /* (non-Javadoc) diff --git a/org.springframework.integration.ip/src/main/java/org/springframework/integration/ip/tcp/TcpNetReceivingChannelAdapter.java b/org.springframework.integration.ip/src/main/java/org/springframework/integration/ip/tcp/TcpNetReceivingChannelAdapter.java index 02043634df..e5463bc399 100644 --- a/org.springframework.integration.ip/src/main/java/org/springframework/integration/ip/tcp/TcpNetReceivingChannelAdapter.java +++ b/org.springframework.integration.ip/src/main/java/org/springframework/integration/ip/tcp/TcpNetReceivingChannelAdapter.java @@ -69,17 +69,16 @@ public class TcpNetReceivingChannelAdapter extends }}); } } catch (IOException e) { - if (!active) { - if (serverSocket != null) { - try { - serverSocket.close(); - } catch (IOException e1) {} - } - serverSocket = null; - return; + if (serverSocket != null) { + try { + serverSocket.close(); + } catch (IOException e1) {} } - // TODO Auto-generated catch block - e.printStackTrace(); + serverSocket = null; + if (active) { + logger.error("Error on ServerSocket", e); + } + } } @@ -101,8 +100,6 @@ public class TcpNetReceivingChannelAdapter extends customSocketReader.getConstructor(Socket.class); reader = BeanUtils.instantiateClass(ctor, socket); } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); throw new MessageMappingException("Failed to instantiate custom reader", e); } } diff --git a/org.springframework.integration.ip/src/main/java/org/springframework/integration/ip/tcp/TcpNetSendingMessageHandler.java b/org.springframework.integration.ip/src/main/java/org/springframework/integration/ip/tcp/TcpNetSendingMessageHandler.java index 0c1e723fd2..77ba56ad3f 100644 --- a/org.springframework.integration.ip/src/main/java/org/springframework/integration/ip/tcp/TcpNetSendingMessageHandler.java +++ b/org.springframework.integration.ip/src/main/java/org/springframework/integration/ip/tcp/TcpNetSendingMessageHandler.java @@ -64,8 +64,7 @@ public class TcpNetSendingMessageHandler extends writer.setMessageFormat(messageFormat); this.writer = writer; } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); + logger.error("Error creating SocketWriter", e); } } return this.writer; diff --git a/org.springframework.integration.ip/src/main/java/org/springframework/integration/ip/tcp/TcpNioReceivingChannelAdapter.java b/org.springframework.integration.ip/src/main/java/org/springframework/integration/ip/tcp/TcpNioReceivingChannelAdapter.java index bce73cd76a..c4a60bbca5 100644 --- a/org.springframework.integration.ip/src/main/java/org/springframework/integration/ip/tcp/TcpNioReceivingChannelAdapter.java +++ b/org.springframework.integration.ip/src/main/java/org/springframework/integration/ip/tcp/TcpNioReceivingChannelAdapter.java @@ -74,18 +74,13 @@ public class TcpNioReceivingChannelAdapter extends doSelect(serverChannel, selector); } catch (IOException e) { - if (!active) { - try { - serverChannel.close(); - } catch (IOException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } - serverChannel = null; - return; + try { + serverChannel.close(); + } catch (IOException e1) { } + serverChannel = null; + if (active) { + logger.error("Error on ServerSocketChannel", e); } - // TODO Auto-generated catch block - e.printStackTrace(); } } @@ -127,6 +122,9 @@ public class TcpNioReceivingChannelAdapter extends key.interestOps(key.interestOps() - key.readyOps()); if (key.attachment() == null) { NioSocketReader reader = createSocketReader(key); + if (reader == null) { + continue; + } key.attach(reader); } this.threadPoolTaskScheduler.execute(new Runnable() { @@ -162,8 +160,7 @@ public class TcpNioReceivingChannelAdapter extends .getConstructor(SocketChannel.class); reader = BeanUtils.instantiateClass(ctor, channel); } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); + logger.error("Error creating SocketReader", e); } } else { reader = new NioSocketReader(channel); diff --git a/org.springframework.integration.ip/src/main/java/org/springframework/integration/ip/tcp/TcpNioSendingMessageHandler.java b/org.springframework.integration.ip/src/main/java/org/springframework/integration/ip/tcp/TcpNioSendingMessageHandler.java index 28f1c1c9dd..f84a6f712f 100644 --- a/org.springframework.integration.ip/src/main/java/org/springframework/integration/ip/tcp/TcpNioSendingMessageHandler.java +++ b/org.springframework.integration.ip/src/main/java/org/springframework/integration/ip/tcp/TcpNioSendingMessageHandler.java @@ -61,8 +61,7 @@ public class TcpNioSendingMessageHandler extends writer.setUsingDirectBuffers(usingDirectBuffers); this.writer = writer; } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); + logger.error("Error creating SocketWriter", e); } } return this.writer; diff --git a/org.springframework.integration.ip/src/test/java/org/springframework/integration/ip/udp/UdpMulticastEndToEndTests.java b/org.springframework.integration.ip/src/test/java/org/springframework/integration/ip/udp/UdpMulticastEndToEndTests.java index ce73eea32e..4239e3e352 100644 --- a/org.springframework.integration.ip/src/test/java/org/springframework/integration/ip/udp/UdpMulticastEndToEndTests.java +++ b/org.springframework.integration.ip/src/test/java/org/springframework/integration/ip/udp/UdpMulticastEndToEndTests.java @@ -38,7 +38,6 @@ import org.springframework.integration.message.StringMessage; /** * Sends and receives a simple message through to the Udp channel adapters. * If run as a JUnit just sends one message and terminates (see console). - * TODO: Use a custom output stream and catch output to verify. * * If run from main(), * hangs around for a couple of minutes to allow console interaction (enter a message on the