http-client-branch: review comment: possible NPE in tests http-client-branch
authorchegar
Tue, 12 Jun 2018 10:38:31 +0100
branchhttp-client-branch
changeset 56744 efbae6e5b3cd
parent 56736 705824c1e596
child 56745 b75307ee399a
http-client-branch: review comment: possible NPE in tests
test/jdk/java/net/httpclient/HandshakeFailureTest.java
test/jdk/java/net/httpclient/InvalidSSLContextTest.java
test/jdk/java/net/httpclient/ssltest/CertificateTest.java
--- a/test/jdk/java/net/httpclient/HandshakeFailureTest.java	Mon Jun 11 15:48:55 2018 +0100
+++ b/test/jdk/java/net/httpclient/HandshakeFailureTest.java	Tue Jun 12 10:38:31 2018 +0100
@@ -166,14 +166,15 @@
     }
 
     static void checkExceptionOrCause(Class<? extends Throwable> clazz, Throwable t) {
+        final Throwable original = t;
         do {
             if (clazz.isInstance(t)) {
                 System.out.println("Found expected exception/cause: " + t);
                 return; // found
             }
         } while ((t = t.getCause()) != null);
-        t.printStackTrace(System.out);
-        throw new RuntimeException("Expected " + clazz + "in " + t);
+        original.printStackTrace(System.out);
+        throw new RuntimeException("Expected " + clazz + "in " + original);
     }
 
     /** Common supertype for PlainServer and SSLServer. */
--- a/test/jdk/java/net/httpclient/InvalidSSLContextTest.java	Mon Jun 11 15:48:55 2018 +0100
+++ b/test/jdk/java/net/httpclient/InvalidSSLContextTest.java	Tue Jun 12 10:38:31 2018 +0100
@@ -134,13 +134,14 @@
         if (t == null) {
             Assert.fail("Expected " + clazz + ", caught nothing");
         }
+        final Throwable original = t;
         do {
             if (clazz.isInstance(t)) {
                 return; // found
             }
         } while ((t = t.getCause()) != null);
-        t.printStackTrace(System.out);
-        Assert.fail("Expected " + clazz + "in " + t);
+        original.printStackTrace(System.out);
+        Assert.fail("Expected " + clazz + "in " + original);
     }
 
     @BeforeTest
--- a/test/jdk/java/net/httpclient/ssltest/CertificateTest.java	Mon Jun 11 15:48:55 2018 +0100
+++ b/test/jdk/java/net/httpclient/ssltest/CertificateTest.java	Tue Jun 12 10:38:31 2018 +0100
@@ -144,13 +144,14 @@
     }
 
     static void checkExceptionOrCause(Class<? extends Throwable> clazz, Throwable t) {
+        final Throwable original = t;
         do {
             if (clazz.isInstance(t)) {
                 System.out.println("Found expected exception/cause: " + t);
                 return; // found
             }
         } while ((t = t.getCause()) != null);
-        t.printStackTrace(System.out);
-        throw new RuntimeException("Expected " + clazz + "in " + t);
+        original.printStackTrace(System.out);
+        throw new RuntimeException("Expected " + clazz + "in " + original);
     }
 }