changeset 395:11325bebcc6c

Runner should throw RunnerException only.
author shade
date Thu, 13 Feb 2014 00:51:28 +0400
parents 545012959ccb
children ea56528a6677
files jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java jmh-core/src/main/java/org/openjdk/jmh/runner/RunnerException.java
diffstat 2 files changed, 13 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java	Wed Feb 12 16:15:57 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java	Thu Feb 13 00:51:28 2014 +0400
@@ -127,16 +127,21 @@
      * This method is handy when Options describe only the single benchmark to run.
      *
      * @return benchmark result
-     * @throws IllegalStateException if more than one benchmark is found
+     * @throws RunnerException if more than one benchmark is found, or no results are returned
      */
     public RunResult runSingle() throws RunnerException {
         Set<BenchmarkRecord> benchmarks = list.find(out, options.getIncludes(), options.getExcludes());
 
         if (benchmarks.size() == 1) {
             Map<BenchmarkRecord, RunResult> rs = run();
-            return rs.values().iterator().next();
+            Collection<RunResult> values = rs.values();
+            if (values.size() == 1) {
+                return values.iterator().next();
+            } else {
+                throw new RunnerException("No results returned");
+            }
         } else {
-            throw new IllegalStateException("More than single benchmark is matching the options");
+            throw new RunnerException("More than single benchmark is matching the options");
         }
     }
 
--- a/jmh-core/src/main/java/org/openjdk/jmh/runner/RunnerException.java	Wed Feb 12 16:15:57 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/RunnerException.java	Thu Feb 13 00:51:28 2014 +0400
@@ -33,7 +33,12 @@
         super();
     }
 
+    public RunnerException(String s) {
+        super(s);
+    }
+
     public RunnerException(String s, Throwable cause) {
         super(s, cause);
     }
+
 }