test/jdk/java/net/Authenticator/B4678055.java
changeset 58009 0daf32316b47
parent 55399 46049b8a5658
child 58679 9c3209ff7550
--- a/test/jdk/java/net/Authenticator/B4678055.java	Wed Sep 04 17:36:53 2019 +0100
+++ b/test/jdk/java/net/Authenticator/B4678055.java	Wed Sep 04 18:10:07 2019 +0100
@@ -38,8 +38,8 @@
 
 public class B4678055 implements HttpCallback {
 
-    static int count = 0;
-    static String authstring;
+    static volatile int count = 0;
+    static volatile String authstring;
 
     void errorReply (HttpTransaction req, String reply) throws IOException {
         req.addResponseHeader ("Connection", "close");
@@ -56,6 +56,7 @@
 
     public void request (HttpTransaction req) {
         try {
+            System.out.println("Server handling case: "+ count);
             authstring = req.getRequestHeader ("Authorization");
             System.out.println (authstring);
             switch (count) {
@@ -95,6 +96,7 @@
             }
             count ++;
         } catch (IOException e) {
+            System.err.println("Unexpected exception for case " + count + ": " + e);
             e.printStackTrace();
         }
     }
@@ -143,6 +145,8 @@
             client(serverURL + "d2/foo.html");
             client(serverURL + "d2/foo.html");
         } catch (Exception e) {
+            System.out.println("Client got exception: " + e);
+            System.out.println("Terminating server");
             if (server != null) {
                 server.terminate();
             }
@@ -156,10 +160,13 @@
         if (!checkFinalAuth()) {
             except ("Wrong authorization string received from client");
         }
+        System.out.println("Terminating server");
         server.terminate();
     }
 
     public static void except (String s) {
+        System.out.println("Check failed: " + s);
+        System.out.println("Terminating server");
         server.terminate();
         throw new RuntimeException (s);
     }
@@ -169,7 +176,7 @@
             super ();
         }
 
-        int count = 0;
+        volatile int count = 0;
 
         public PasswordAuthentication getPasswordAuthentication () {
             PasswordAuthentication pw;