Response response;
if (responses.size() > 1) {
// Remove duplicates before deciding if multiple responses were received
Set<Response> setResponses = new HashSet<Response>(responses);
if (setResponses.size() > 1)
throw new CacheLoaderException(String.format(
"Responses contains more than 1 element and these elements are not equal, so can't decide which one to use: %s",
setResponses));
response = setResponses.iterator().next();
} else {
response = responses.iterator().next();
}
if (response.isSuccessful() && response instanceof SuccessfulResponse) {
InternalCacheValue value = (InternalCacheValue) ((SuccessfulResponse) response).getResponseValue();
return ctx.getMarshalledEntryFactory().newMarshalledEntry(key, value.getValue(), null);
}
log.unknownResponsesFromRemoteCache(responses);
throw new CacheLoaderException("Unknown responses");
}