8230854: Cleanup SuppressWarnings in test lib and remove noisy traces in StreamPumper
authorclanger
Mon, 16 Sep 2019 09:28:54 +0200
changeset 58144 d003b3ef8b60
parent 58143 b35771556cd0
child 58149 00aebe177a71
child 58163 64911d7edff9
8230854: Cleanup SuppressWarnings in test lib and remove noisy traces in StreamPumper Reviewed-by: stuefe, dholmes
test/lib/jdk/test/lib/Platform.java
test/lib/jdk/test/lib/Utils.java
test/lib/jdk/test/lib/process/ProcessTools.java
test/lib/jdk/test/lib/process/StreamPumper.java
--- a/test/lib/jdk/test/lib/Platform.java	Mon Sep 16 09:21:42 2019 +0200
+++ b/test/lib/jdk/test/lib/Platform.java	Mon Sep 16 09:28:54 2019 +0200
@@ -265,7 +265,6 @@
                     return false;
                 }
             } catch (PrivilegedActionException e) {
-                @SuppressWarnings("unchecked")
                 IOException t = (IOException) e.getException();
                 throw t;
             }
@@ -289,7 +288,6 @@
                     return false;
                 }
             } catch (PrivilegedActionException e) {
-                @SuppressWarnings("unchecked")
                 IOException t = (IOException) e.getException();
                 throw t;
             }
--- a/test/lib/jdk/test/lib/Utils.java	Mon Sep 16 09:21:42 2019 +0200
+++ b/test/lib/jdk/test/lib/Utils.java	Mon Sep 16 09:28:54 2019 +0200
@@ -25,6 +25,7 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.lang.annotation.Annotation;
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.net.MalformedURLException;
@@ -749,13 +750,14 @@
     // until the method main() is found; the class containing that method is the
     // main test class and will be returned as the name of the test.
     // Special handling is used for testng tests.
+    @SuppressWarnings("unchecked")
     public static String getTestName() {
         String result = null;
         // If we are using testng, then we should be able to load the "Test" annotation.
-        Class testClassAnnotation;
+        Class<? extends Annotation> testClassAnnotation;
 
         try {
-            testClassAnnotation = Class.forName("org.testng.annotations.Test");
+            testClassAnnotation = (Class<? extends Annotation>)Class.forName("org.testng.annotations.Test");
         } catch (ClassNotFoundException e) {
             testClassAnnotation = null;
         }
@@ -776,7 +778,7 @@
             // annotation. If present, then use the name of this class.
             if (testClassAnnotation != null) {
                 try {
-                    Class c = Class.forName(className);
+                    Class<?> c = Class.forName(className);
                     if (c.isAnnotationPresent(testClassAnnotation)) {
                         result = className;
                         break;
--- a/test/lib/jdk/test/lib/process/ProcessTools.java	Mon Sep 16 09:21:42 2019 +0200
+++ b/test/lib/jdk/test/lib/process/ProcessTools.java	Mon Sep 16 09:28:54 2019 +0200
@@ -495,7 +495,6 @@
             return AccessController.doPrivileged(
                 (PrivilegedExceptionAction<Process>) () -> pb.start());
         } catch (PrivilegedActionException e) {
-            @SuppressWarnings("unchecked")
             IOException t = (IOException) e.getException();
             throw t;
         }
--- a/test/lib/jdk/test/lib/process/StreamPumper.java	Mon Sep 16 09:21:42 2019 +0200
+++ b/test/lib/jdk/test/lib/process/StreamPumper.java	Mon Sep 16 09:28:54 2019 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2019, 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
@@ -144,7 +144,9 @@
             }
 
         } catch (IOException e) {
-            e.printStackTrace();
+            if (!e.getMessage().equalsIgnoreCase("stream closed")) {
+                e.printStackTrace();
+            }
         } finally {
             for (OutputStream out : outStreams) {
                 try {