8076644: MulticastSendReceiveTests.java fails with NumberFormatException due to network interference
authorchegar
Fri, 03 Apr 2015 16:09:49 +0100
changeset 29746 f0730dd3de62
parent 29745 119626a43008
child 29747 0ab8f74c7f13
8076644: MulticastSendReceiveTests.java fails with NumberFormatException due to network interference Reviewed-by: alanb
jdk/test/java/nio/channels/DatagramChannel/MulticastSendReceiveTests.java
--- a/jdk/test/java/nio/channels/DatagramChannel/MulticastSendReceiveTests.java	Fri Apr 03 00:00:16 2015 -0700
+++ b/jdk/test/java/nio/channels/DatagramChannel/MulticastSendReceiveTests.java	Fri Apr 03 16:09:49 2015 +0100
@@ -97,7 +97,7 @@
                 // no datagram received
                 if (sa == null) {
                     if (expectedSender != null) {
-                        throw new RuntimeException("Expected message not recieved");
+                        throw new RuntimeException("Expected message not received");
                     }
                     System.out.println("No message received (correct)");
                     return;
@@ -109,10 +109,15 @@
                 buf.flip();
                 byte[] bytes = new byte[buf.remaining()];
                 buf.get(bytes);
-                int receivedId = Integer.parseInt(new String(bytes));
-
-                System.out.format("Received message from %s (id=0x%x)\n",
-                    sender, receivedId);
+                String s = new String(bytes, "UTF-8");
+                int receivedId = -1;
+                try {
+                    receivedId = Integer.parseInt(s);
+                    System.out.format("Received message from %s (id=0x%x)\n",
+                            sender, receivedId);
+                } catch (NumberFormatException x) {
+                    System.out.format("Received message from %s (msg=%s)\n", sender, s);
+                }
 
                 if (expectedSender == null) {
                     if (receivedId == id)