Skip to content

Commit

Permalink
Gracefully fallback to queue-time sorting if items are unknown
Browse files Browse the repository at this point in the history
  • Loading branch information
emsa23 committed May 11, 2015
1 parent fdfe38d commit b6bf3e4
Showing 1 changed file with 5 additions and 1 deletion.
Expand Up @@ -67,7 +67,7 @@ public int compare(BuildableItem o1, BuildableItem o2) {
// Listener called before we get here so make sure we mark buildable
QueueItemCache.get().getItem(item.id).setBuildable();
}
LOGGER.fine("Initialized the QueueSorter with " + items.size() + " Buildable Items");
LOGGER.info("Initialized the QueueSorter with " + items.size() + " Buildable Items");
}

@Override
Expand All @@ -77,6 +77,10 @@ public void sortBuildableItems(List<BuildableItem> items) {
public int compare(BuildableItem o1, BuildableItem o2) {
ItemInfo item1 = QueueItemCache.get().getItem(o1.id);
ItemInfo item2 = QueueItemCache.get().getItem(o2.id);
if(item1 == null || item2 == null) {
LOGGER.warning("Requested to sort unknown items, sorting on queue-time only.");
return new Long(o1.getInQueueSince()).compareTo(o2.getInQueueSince());
}
return item1.compareTo(item2);
}
});
Expand Down

0 comments on commit b6bf3e4

Please sign in to comment.