test/lib/jdk/test/lib/Utils.java
changeset 51478 36c72eb60d5b
parent 50367 b73f9723aa54
child 53903 68bbd727dd5f
--- a/test/lib/jdk/test/lib/Utils.java	Fri Aug 17 13:53:53 2018 -0700
+++ b/test/lib/jdk/test/lib/Utils.java	Wed Aug 22 11:10:45 2018 +0800
@@ -612,7 +612,7 @@
      * @param runnable what we run
      * @param expectedException expected exception
      */
-    public static void runAndCheckException(Runnable runnable, Class<? extends Throwable> expectedException) {
+    public static void runAndCheckException(ThrowingRunnable runnable, Class<? extends Throwable> expectedException) {
         runAndCheckException(runnable, t -> {
             if (t == null) {
                 if (expectedException != null) {
@@ -635,13 +635,14 @@
      * @param runnable what we run
      * @param checkException a consumer which checks that we got expected exception and raises a new exception otherwise
      */
-    public static void runAndCheckException(Runnable runnable, Consumer<Throwable> checkException) {
+    public static void runAndCheckException(ThrowingRunnable runnable, Consumer<Throwable> checkException) {
+        Throwable throwable = null;
         try {
             runnable.run();
-            checkException.accept(null);
         } catch (Throwable t) {
-            checkException.accept(t);
+            throwable = t;
         }
+        checkException.accept(throwable);
     }
 
     /**