aboutsummaryrefslogtreecommitdiff
path: root/test/java/nio/channels
diff options
context:
space:
mode:
authorchegar <none@none>2011-08-25 16:08:31 +0100
committerchegar <none@none>2011-08-25 16:08:31 +0100
commit3905bfd4859cc5c339e81f123f75e441202844ae (patch)
tree8220d0003d81966c5229642acddbd415f84080a0 /test/java/nio/channels
parentc239240e05806c7e70041f04dc8870f45193ae18 (diff)
7044870: java/nio/channels/DatagramChannel/SelectWhenRefused.java failed on SUSE Linux 10
Reviewed-by: alanb, chegar Contributed-by: kurchi.subhra.hazra@oracle.com
Diffstat (limited to 'test/java/nio/channels')
-rw-r--r--test/java/nio/channels/DatagramChannel/SelectWhenRefused.java17
1 files changed, 12 insertions, 5 deletions
diff --git a/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java b/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java
index 6d444d50f..426a98eb8 100644
--- a/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java
+++ b/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java
@@ -22,7 +22,7 @@
*/
/* @test
- * @bug 6935563
+ * @bug 6935563 7044870
* @summary Test that Selector does not select an unconnected DatagramChannel when
* ICMP port unreachable received
*/
@@ -35,14 +35,15 @@ import java.io.IOException;
public class SelectWhenRefused {
public static void main(String[] args) throws IOException {
- DatagramChannel dc = DatagramChannel.open().bind(new InetSocketAddress(0));
- int port = dc.socket().getLocalPort();
- dc.close();
+ DatagramChannel dc1 = DatagramChannel.open().bind(new InetSocketAddress(0));
+ int port = dc1.socket().getLocalPort();
// datagram sent to this address should be refused
SocketAddress refuser = new InetSocketAddress(InetAddress.getLocalHost(), port);
- dc = DatagramChannel.open().bind(new InetSocketAddress(0));
+ DatagramChannel dc = DatagramChannel.open().bind(new InetSocketAddress(0));
+ dc1.close();
+
Selector sel = Selector.open();
try {
dc.configureBlocking(false);
@@ -52,6 +53,10 @@ public class SelectWhenRefused {
sendDatagram(dc, refuser);
int n = sel.select(2000);
if (n > 0) {
+ sel.selectedKeys().clear();
+ // BindException will be thrown if another service is using
+ // our expected refuser port, cannot run just exit.
+ DatagramChannel.open().bind(refuser).close();
throw new RuntimeException("Unexpected wakeup");
}
@@ -80,6 +85,8 @@ public class SelectWhenRefused {
throw new RuntimeException("Unexpected wakeup after disconnect");
}
+ } catch(BindException e) {
+ // Do nothing, some other test has used this port
} finally {
sel.close();
dc.close();