changeset 135:309279f710b7

Always shutdown microbenchmark handler.
author shade
date Wed, 21 Aug 2013 21:26:58 +0400
parents 3b358eae06de
children 7ba43108f829
files jmh-core/src/main/java/org/openjdk/jmh/runner/BaseRunner.java
diffstat 1 files changed, 6 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/jmh-core/src/main/java/org/openjdk/jmh/runner/BaseRunner.java	Wed Aug 21 21:17:17 2013 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/BaseRunner.java	Wed Aug 21 21:26:58 2013 +0400
@@ -61,22 +61,24 @@
     }
 
     void runBenchmark(BenchmarkRecord benchmark, boolean doWarmup, boolean doMeasurement) {
+        MicroBenchmarkHandler handler = null;
         try {
             Class<?> clazz = ClassUtils.loadClass(benchmark.generatedClass());
             Method method = MicroBenchmarkHandlers.findBenchmarkMethod(clazz, benchmark.generatedMethod());
 
             MicroBenchmarkParameters executionParams = MicroBenchmarkParametersFactory.makeParams(options, benchmark, method, doWarmup, doMeasurement);
-            MicroBenchmarkHandler handler = MicroBenchmarkHandlers.getInstance(out, benchmark, clazz, method, executionParams, options);
+            handler = MicroBenchmarkHandlers.getInstance(out, benchmark, clazz, method, executionParams, options);
 
             runBenchmark(executionParams, handler);
-
-            handler.shutdown();
-
         } catch (Throwable ex) {
             out.exception(ex);
             if (this.options.shouldFailOnError()) {
                 throw new IllegalStateException(ex.getMessage(), ex);
             }
+        } finally {
+            if (handler != null) {
+                handler.shutdown();
+            }
         }
     }