When testing with less load in local it worked fine.
private static class CoordinateComparator implements Comparator<Coordinate> {
@Override
public int compare(Coordinate o1, Coordinate o2) {
return o1.x <= o2.x ? -1 : 1;
}
}
Here x is primitive and it was giving runtime error when tests were run. Under heavy load it was breaking.
Then i changed comparator to:-
private static class CoordinateComparator implements Comparator<Coordinate> {
@Override
public int compare(Coordinate o1, Coordinate o2) {
return o1.x.compareTo(o2.x);
}
}
In this case x is Integer. Then it started working fine. Any ideas or thoughts why this was happening. I was passing this comparator to Collections.sort(array, comp)