Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
1.5.6, 1.6-beta-1
-
None
Description
groovy.lang.ObjectRange.size() disobeys its contract for large ranges of Long values: "Returns the number of elements in this list. If this list contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE."
println (new ObjectRange(0L, (long)Integer.MAX_VALUE).size()) // -2147483648
println (new ObjectRange(0L, (2L<<32)-2).size()) // -1
A similar error is to be expected for BigDecimal ranges and other ranges larger than Integer.MAX_VALUE, though with other kinds of ranges the computation of size takes a while.
Expected behaviour:
assert Integer.MAX_VALUE == new ObjectRange(0L, Integer.MAX_VALUE + 1L).size()