// because that would result in nobody seeing the list.
// Therefore, we bias towards case 2 which Freetalk should be able to handle well:
// It is normal for content to fall out of the network, therefore the USK queue must be able to deal well with empty slots.
for(final MessageList list : result) {
FetchFailedMarker marker;
if(!(list instanceof OwnMessageList)) {
// If the list is no OwnMessageList, it might be a ghost list only for a data-not-found slot... we shall ignore
// those lists in the computation, so we check whether there is a FetchFailedMarker
try {
marker = getMessageListFetchFailedMarker(list.getID());
} catch(NoSuchFetchFailedMarkerException e) {
marker = null;
}
} else {
// The list is an OwnMessageList, we MUST NOT check for a FetchFailedMarker: We ignore DataNotFound non-own MessageLists when
// returning a free slot index, so both an OwnMessageList and a MessageList with DNF FetchFailedMarker might exist at once
// for the same index. If we DID take its FetchFailedMarker into consideration, the index would be returned by this function
// even though an OwnMessageList exists for that index already.
marker = null;
}
if(marker == null || marker.getReason() != FetchFailedMarker.Reason.DataNotFound)
return list.getIndex() + 1;
}
// There are no message lists or all are marked as DNF => Slot 0 must be free, return it.
return 0;