Guard against exceptions thrown by implementations of Queue.Task.getAffinityKey
@@ -112,7 +112,14 @@ public abstract class LoadBalancer implements ExtensionPoint {
private boolean assignGreedily(Mapping m, Task task, List<ConsistentHash<ExecutorChunk>> hashes, int i) {
if (i==hashes.size()) return true; // fully assigned
- String key = task.getAffinityKey() + (i>0 ? String.valueOf(i) : "");
+ String key;
+ try {
+ key = task.getAffinityKey();
+ } catch (RuntimeException e) {
+ // Default implementation of Queue.Task.getAffinityKey, we assume it doesn't fail.
+ key = task.getFullDisplayName();
+ }
+ key += i > 0 ? String.valueOf(i) : "";
for (ExecutorChunk ec : hashes.get(i).list(key)) {
// let's attempt this assignment
