changeset 340:c16c2f7fa79b

Make sure embedded and forked executors report exceptions consistently, and never miss one.
author shade
date Mon, 19 Dec 2016 16:34:39 +0100
parents 2e689d5a271a
children 0de8079ec104
files jcstress-core/src/main/java/org/openjdk/jcstress/EmbeddedExecutor.java jcstress-core/src/main/java/org/openjdk/jcstress/infra/runners/Runner.java
diffstat 2 files changed, 7 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/jcstress-core/src/main/java/org/openjdk/jcstress/EmbeddedExecutor.java	Thu Nov 17 16:01:03 2016 +0100
+++ b/jcstress-core/src/main/java/org/openjdk/jcstress/EmbeddedExecutor.java	Mon Dec 19 16:34:39 2016 +0100
@@ -78,17 +78,18 @@
                 Constructor<?> cnstr = aClass.getConstructor(TestConfig.class, TestResultCollector.class, ExecutorService.class);
                 Runner<?> o = (Runner<?>) cnstr.newInstance(config, sink, pool);
                 o.run();
-            } catch (ClassFormatError e) {
+            } catch (ClassFormatError | NoClassDefFoundError | NoSuchMethodError | NoSuchFieldError e) {
                 TestResult result = new TestResult(config, Status.API_MISMATCH, 0);
                 result.addAuxData(e.getMessage());
                 sink.add(result);
-            } catch (Exception ex) {
+            } catch (Throwable ex) {
                 TestResult result = new TestResult(config, Status.TEST_ERROR, 0);
                 result.addAuxData(ex.getMessage());
                 sink.add(result);
-            }
-            if (onFinish != null) {
-                onFinish.accept(config);
+            } finally {
+                if (onFinish != null) {
+                    onFinish.accept(config);
+                }
             }
         };
     }
--- a/jcstress-core/src/main/java/org/openjdk/jcstress/infra/runners/Runner.java	Thu Nov 17 16:01:03 2016 +0100
+++ b/jcstress-core/src/main/java/org/openjdk/jcstress/infra/runners/Runner.java	Mon Dec 19 16:34:39 2016 +0100
@@ -70,7 +70,7 @@
     public void run() {
         try {
             sanityCheck();
-        } catch (NoClassDefFoundError | NoSuchMethodError | NoSuchFieldError e) {
+        } catch (ClassFormatError | NoClassDefFoundError | NoSuchMethodError | NoSuchFieldError e) {
             dumpFailure(-1, Status.API_MISMATCH, "Test sanity check failed, skipping", e);
             return;
         } catch (Throwable e) {