Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.1-beta-1
-
Fix Version/s: 1.1-beta-2
-
Component/s: None
-
Labels:None
-
Number of attachments :
Description
For this list:
def x = [1, 2, 3, 1, 2, 3, null, 'a', null]
Both these throw NPE:
println x.unique() println x.sort()
In DefaultGroovyMethods.java, locate the inner class NumberComparator.
Instead of
public int compare(Object o1, Object o2) {
if (o1 instanceof Number && o2 instanceof Number) {
...
check for null first:
public int compare(Object o1, Object o2) {
{ return o2==null?0:-1; }if (o1 == null)
else if (o2 == null)
{ return 1; }else if (o1 instanceof Number && o2 instanceof Number) {
...
This solves the NPE problem.