changeset 8240:ed6e798f44e1 jdk7u79-b12

8065072: sun/net/www/http/HttpClient/StreamingRetry.java failed intermittently Reviewed-by: dfuchs
author chegar
date Fri, 27 Feb 2015 09:05:41 -0800
parents 643166b10b98
children 1978a68004af
files test/sun/net/www/http/HttpClient/StreamingRetry.java
diffstat 1 files changed, 8 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/test/sun/net/www/http/HttpClient/StreamingRetry.java	Thu Apr 09 17:21:14 2015 -0700
+++ b/test/sun/net/www/http/HttpClient/StreamingRetry.java	Fri Feb 27 09:05:41 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015, 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
@@ -36,23 +36,24 @@
 
 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 {
         test();
         if (failed > 0) throw new RuntimeException("Some tests failed");
     }
 
-    void test() 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 + "/");
@@ -68,6 +69,7 @@
             //expected.printStackTrace();
         } finally {
             ss.close();
+            otherThread.join();
         }
     }