Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8209771

jdk.test.lib.Utils::runAndCheckException error

XMLWordPrintable

    • b09

        test/lib/jdk/test/lib/Utils.java

            public static void runAndCheckException(Runnable runnable, Consumer<Throwable> checkException) {
                try {
                    runnable.run();
                    checkException.accept(null);
                } catch (Throwable t) {
                    checkException.accept(t);
                }
            }

        Suppose checkException.accept(null) throws a Throwable itself it will be caught and accepted again.

        Also, since this method is mainly used to check for exceptions thrown by runnable, it's better to use ThrowingRunnable (defined in the same source file) than Runnable.

              weijun Weijun Wang
              weijun Weijun Wang
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: