http-client-branch: more fixes for odd intermittent failures http-client-branch
authordfuchs
Wed, 07 Feb 2018 15:46:30 +0000
branchhttp-client-branch
changeset 56091 aedd6133e7a0
parent 56090 5c7fb702948a
child 56092 fd85b2bf2b0d
http-client-branch: more fixes for odd intermittent failures
test/jdk/java/net/httpclient/SmokeTest.java
test/jdk/java/net/httpclient/SplitResponse.java
--- a/test/jdk/java/net/httpclient/SmokeTest.java	Wed Feb 07 15:41:04 2018 +0000
+++ b/test/jdk/java/net/httpclient/SmokeTest.java	Wed Feb 07 15:46:30 2018 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -932,6 +932,7 @@
     }
 
     static final CountDownLatch latch = new CountDownLatch(4);
+    static final CountDownLatch latch7 = new CountDownLatch(4);
     static final CountDownLatch latch8 = new CountDownLatch(1);
 
     @Override
@@ -965,8 +966,11 @@
             setPort(n, remotePort);
             latch.countDown();
             try {latch.await();} catch (InterruptedException e) {}
+            latch7.countDown();
         }
         if (n == 7) {
+            // wait until all n <= 7 have called setPort(...)
+            try {latch7.await();} catch (InterruptedException e) {}
             getPorts(lports, 4);
             // should be all different
             if (lports[0] == lports[1] || lports[2] == lports[3]
@@ -983,13 +987,15 @@
         }
         // Third test
         if (n > 7) {
+            // wait until all n == 7 has updated portSet
             try {latch8.await();} catch (InterruptedException e) {}
             if (np > 4) {
                 System.err.println("XXX np = " + np);
             }
             // just check that port is one of the ones in portSet
             if (!portSet.contains(remotePort)) {
-                System.out.println ("UNEXPECTED REMOTE PORT " + remotePort);
+                System.out.println ("UNEXPECTED REMOTE PORT "
+                        + remotePort + " not in " + portSet);
                 result = "Error " + Integer.toString(n);
                 System.out.println(result);
             }
--- a/test/jdk/java/net/httpclient/SplitResponse.java	Wed Feb 07 15:41:04 2018 +0000
+++ b/test/jdk/java/net/httpclient/SplitResponse.java	Wed Feb 07 15:46:30 2018 +0000
@@ -22,6 +22,7 @@
  */
 
 import java.io.IOException;
+import java.net.SocketException;
 import java.net.URI;
 import java.util.concurrent.CompletableFuture;
 import javax.net.ssl.SSLContext;
@@ -219,7 +220,23 @@
                 out.println("Server: going to send [" + s + "]");
                 for (int i = 0; i < len; i++) {
                     String onechar = s.substring(i, i + 1);
-                    conn.send(onechar);
+                    try {
+                        conn.send(onechar);
+                    } catch(SocketException x) {
+                        if (!useSSL || i != len - 1) throw x;
+                        if (x.getMessage().contains("closed by remote host")) {
+                            String osname = System.getProperty("os.name", "unknown");
+                            // On Solaris we can receive an exception when
+                            // the client closes the connection after receiving
+                            // the last expected char.
+                            if (osname.contains("SunO")) {
+                                System.out.println(osname + " detected");
+                                System.out.println("WARNING: ignoring " + x);
+                                System.err.println(osname + " detected");
+                                System.err.println("WARNING: ignoring " + x);
+                            }
+                        }
+                    }
                     Thread.sleep(10);
                 }
                 out.println("Server: sent [" + s + "]");