From f2034e6bbad86bbca7549a7e982fcbedfe6d91b2 Mon Sep 17 00:00:00 2001 From: Chris Hegarty Date: Tue, 16 Mar 2010 10:05:51 +0000 Subject: [PATCH] 6934923: test/java/net/ipv6tests/TcpTest.java hangs on Solaris 10 Reviewed-by: alanb --- jdk/test/java/net/ipv6tests/TcpTest.java | 8 +++--- jdk/test/java/net/ipv6tests/Tests.java | 33 +++++++++++++++++------- 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/jdk/test/java/net/ipv6tests/TcpTest.java b/jdk/test/java/net/ipv6tests/TcpTest.java index ec07a8bdd1a..38bb74513a8 100644 --- a/jdk/test/java/net/ipv6tests/TcpTest.java +++ b/jdk/test/java/net/ipv6tests/TcpTest.java @@ -47,9 +47,11 @@ public class TcpTest extends Tests { try { ia4any = InetAddress.getByName ("0.0.0.0"); ia6any = InetAddress.getByName ("::0"); - int scope = ia6addr.getScopeId(); - if (scope != 0) { - ia6bad = InetAddress.getByName ("fe80::1:2:3:4:5:6%"+scope); + if (ia6addr != null) { + int scope = ia6addr.getScopeId(); + if (scope != 0) { + ia6bad = InetAddress.getByName ("fe80::1:2:3:4:5:6%"+scope); + } } else { ia6bad = InetAddress.getByName ("fe80::1:2:3:4:5:6"); } diff --git a/jdk/test/java/net/ipv6tests/Tests.java b/jdk/test/java/net/ipv6tests/Tests.java index 4527427d956..096bd3d2608 100644 --- a/jdk/test/java/net/ipv6tests/Tests.java +++ b/jdk/test/java/net/ipv6tests/Tests.java @@ -38,12 +38,25 @@ public class Tests { OutputStream o1 = s1.getOutputStream(); OutputStream o2 = s2.getOutputStream(); - simpleWrite (o1, 100); - simpleWrite (o2, 200); + startSimpleWriter("SimpleWriter-1", o1, 100); + startSimpleWriter("SimpleWriter-2", o2, 200); simpleRead (i2, 100); simpleRead (i1, 200); } + static void startSimpleWriter(String threadName, final OutputStream os, final int start) { + (new Thread(new Runnable() { + public void run() { + try { simpleWrite(os, start); } + catch (Exception e) {unexpected(e); } + }}, threadName)).start(); + } + + static void unexpected(Exception e ) { + System.out.println("Unexcepted Exception: " + e); + e.printStackTrace(); + } + /** * Send a packet from s1 to s2 (ia2/s2.localPort) and check it * Send a packet from s2 to s1 (ia1/s1.localPort) and check it @@ -247,13 +260,15 @@ public class Tests { } private NetworkInterface getNextIf () { - while (ifs.hasMoreElements()) { - NetworkInterface nic = (NetworkInterface)ifs.nextElement(); - try { - if (nic.isUp() && !nic.isLoopback()) - return nic; - } catch (SocketException e) { - // ignore + if (ifs != null) { + while (ifs.hasMoreElements()) { + NetworkInterface nic = (NetworkInterface)ifs.nextElement(); + try { + if (nic.isUp() && !nic.isLoopback()) + return nic; + } catch (SocketException e) { + // ignore + } } }