You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2015/10/19 19:01:54 UTC

incubator-groovy git commit: Fix after GROOVY-7574: Always do null checks in ObjectRange constructor (closes #149)

Repository: incubator-groovy
Updated Branches:
  refs/heads/master d8cdedeb4 -> b36605fa2


Fix after GROOVY-7574: Always do null checks in ObjectRange constructor (closes #149)


Project: http://git-wip-us.apache.org/repos/asf/incubator-groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-groovy/commit/b36605fa
Tree: http://git-wip-us.apache.org/repos/asf/incubator-groovy/tree/b36605fa
Diff: http://git-wip-us.apache.org/repos/asf/incubator-groovy/diff/b36605fa

Branch: refs/heads/master
Commit: b36605fa292a07025df7f806af876d54779e23e8
Parents: d8cdede
Author: Thibault Kruse <th...@gmx.de>
Authored: Thu Oct 15 10:15:06 2015 +0200
Committer: pascalschumacher <pa...@gmx.net>
Committed: Mon Oct 19 19:01:10 2015 +0200

----------------------------------------------------------------------
 src/main/groovy/lang/ObjectRange.java | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-groovy/blob/b36605fa/src/main/groovy/lang/ObjectRange.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/lang/ObjectRange.java b/src/main/groovy/lang/ObjectRange.java
index a1c0eba..797ae62 100644
--- a/src/main/groovy/lang/ObjectRange.java
+++ b/src/main/groovy/lang/ObjectRange.java
@@ -89,6 +89,11 @@ public class ObjectRange extends AbstractList implements Range {
      * @param reverse direction of the range. If null, causes direction to be computed (can be expensive).
      */
     private ObjectRange(Comparable smaller, Comparable larger, Boolean reverse) {
+        if (smaller == null) {
+            throw new IllegalArgumentException("Must specify a non-null value for the 'from' index in a Range");
+        } else if (larger == null) {
+            throw new IllegalArgumentException("Must specify a non-null value for the 'to' index in a Range");
+        }
         if (reverse == null) {
             boolean computedReverse = areReversed(smaller, larger);
             // ensure invariant from <= to
@@ -155,13 +160,6 @@ public class ObjectRange extends AbstractList implements Range {
     }
 
     private static boolean areReversed(Comparable from, Comparable to) {
-        if (from == null) {
-            throw new IllegalArgumentException("Must specify a non-null value for the 'from' index in a Range");
-        }
-        if (to == null) {
-            throw new IllegalArgumentException("Must specify a non-null value for the 'to' index in a Range");
-        }
-
         try {
             return ScriptBytecodeAdapter.compareGreaterThan(from, to);
         } catch (ClassCastException cce) {