changeset 10312:4d847d8dfedb

8065072: sun/net/www/http/HttpClient/StreamingRetry.java failed intermittently Reviewed-by: dfuchs
author chegar
date Tue, 25 Nov 2014 18:43:44 +0000
parents 481390d5d8ce
children 44cf4e00e1de
files test/sun/net/www/http/HttpClient/StreamingRetry.java
diffstat 1 files changed, 7 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/test/sun/net/www/http/HttpClient/StreamingRetry.java	Fri Dec 05 18:55:29 2014 +0300
+++ b/test/sun/net/www/http/HttpClient/StreamingRetry.java	Tue Nov 25 18:43:44 2014 +0000
@@ -37,13 +37,13 @@
 
 public class StreamingRetry implements Runnable {
     static final int ACCEPT_TIMEOUT = 20 * 1000; // 20 seconds
-    ServerSocket ss;
+    volatile ServerSocket ss;
 
-    public static void main(String[] args) throws IOException {
+    public static void main(String[] args) throws Exception {
         (new StreamingRetry()).instanceMain();
     }
 
-    void instanceMain() throws IOException {
+    void instanceMain() throws Exception {
         out.println("Test with default method");
         test(null);
         out.println("Test with POST method");
@@ -54,12 +54,13 @@
         if (failed > 0) throw new RuntimeException("Some tests failed");
     }
 
-    void test(String method) throws IOException {
+    void test(String method) throws Exception {
         ss = new ServerSocket(0);
         ss.setSoTimeout(ACCEPT_TIMEOUT);
         int port = ss.getLocalPort();
 
-        (new Thread(this)).start();
+        Thread otherThread = new Thread(this);
+        otherThread.start();
 
         try {
             URL url = new URL("http://localhost:" + port + "/");
@@ -77,6 +78,7 @@
             //expected.printStackTrace();
         } finally {
             ss.close();
+            otherThread.join();
         }
     }