From 66566a1acdf29d88b2c73b6ad5cb74670cd212c8 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Thu, 10 Feb 2011 13:29:53 +0100 Subject: [PATCH] Added a timeout for the UdpClient so that the test cannot hang. I noticed the build "hanging/halting" on the test when running the cobertura code coverage Eclipse plugin. --- .../jboss/netty/channel/socket/nio/NioDatagramChannelTest.java | 2 +- .../java/org/jboss/netty/channel/socket/nio/UdpClient.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/jboss/netty/channel/socket/nio/NioDatagramChannelTest.java b/src/test/java/org/jboss/netty/channel/socket/nio/NioDatagramChannelTest.java index e658c6aa7f..5f305ae4f0 100644 --- a/src/test/java/org/jboss/netty/channel/socket/nio/NioDatagramChannelTest.java +++ b/src/test/java/org/jboss/netty/channel/socket/nio/NioDatagramChannelTest.java @@ -112,7 +112,7 @@ public class NioDatagramChannelTest { assertFalse("The payload should have been cleared", expectedPayload .equals(new String(dp.getData()))); - udpClient.receive(dp); + udpClient.receive(dp, 4000); assertEquals(expectedPayload, new String(dp.getData())); udpClient.close(); diff --git a/src/test/java/org/jboss/netty/channel/socket/nio/UdpClient.java b/src/test/java/org/jboss/netty/channel/socket/nio/UdpClient.java index 48b97c90ba..412730af60 100644 --- a/src/test/java/org/jboss/netty/channel/socket/nio/UdpClient.java +++ b/src/test/java/org/jboss/netty/channel/socket/nio/UdpClient.java @@ -48,7 +48,8 @@ public class UdpClient { return dp; } - public void receive(final DatagramPacket dp) throws IOException { + public void receive(final DatagramPacket dp, final int timeout) throws IOException { + clientSocket.setSoTimeout(timeout); clientSocket.receive(dp); }