Hi Phillip,
I don’t know if this is the issue, but there is a potential sort problem in the comparator associated to the error from the stack trace you saw.
This is the compare used by the service registry JPA impl from line #2805
@Override
public int compare(ServiceRegistration serviceA, ServiceRegistration serviceB) {
String hostA = serviceA.getHost();
String hostB = serviceB.getHost();
NodeLoad nodeA = loadByHost.get(hostA);
NodeLoad nodeB = loadByHost.get(hostB);
//If the load factors are about the same, sort based on maximum load
if (Math.abs(nodeA.getLoadFactor() - nodeB.getLoadFactor()) <= 0.01) {
//NOTE: The sort order below is *reversed* from what you'd expect
//When we're comparing the load factors we want the node with the lowest factor to be first
//When we're comparing the maximum load value, we want the node with the highest max to be first
return Float.compare(nodeB.getMaxLoad(), nodeA.getMaxLoad());
}
return Float.compare(nodeA.getLoadFactor(), nodeB.getLoadFactor());
}
Here is an example of how it would return a different sort order depending on input order of objects in the collection:
===================
Input order:
A(x:0.01, y:10)
B(x:0.02, y:5)
C(x:0.03, y:0)
Sort logic:
A > B because |A.x > B.x| <= 0.01 and A.y > B.y
C > A because |C.x - A.x| > 0.01
Resulting sort order:
B(x:0.02, y:5)
A(x:0.01, y:10)
C(x:0.03, y:0)
===============================
Input order:
C(x:0.03, y:0)
B(x:0.02, y:5)
A(x:0.01, y:10)
Sort logic:
B > C because |C.x - B.x| <=0.01 and B.y > C.y
A > B because |A.x > B.x| <= 0.01 and A.y > B.y
Resulting sort order:
C(x:0.03, y:0)
B(x:0.02, y:5)
A(x:0.01, y:10)
- Karen