protected boolean parseResponseAndAddToResponseList(Object responseObject, Throwable exception, Map<Address, Response> responseListToAddTo, boolean wasSuspected,
boolean wasReceived, Address sender, boolean usedResponseFilter, boolean ignoreLeavers)
throws Exception
{
Log log = getLog();
boolean invalidResponse = true;
if (!wasSuspected && wasReceived) {
invalidResponse = false;
if (exception != null) {
log.tracef(exception, "Unexpected exception from %s", sender);
throw new CacheException("Remote (" + sender + ") failed unexpectedly", exception);
}
if (responseObject instanceof Response) {
Response response = (Response) responseObject;
if (response instanceof ExceptionResponse) {
Exception e = ((ExceptionResponse) response).getException();
if (!(e instanceof RpcException)) {
// if we have any application-level exceptions make sure we throw them!!
if (shouldThrowException(e)) {
throw e;
} else {
if (log.isDebugEnabled()) log.debug("Received exception from sender" + sender, e);
}
}
}
responseListToAddTo.put(sender, response);
} else if (responseObject != null) {
// null responses should just be ignored, all other responses should trigger an exception
Class<?> responseClass = responseObject.getClass();
log.tracef("Unexpected response object type from %s: %s", sender, responseClass);
throw new CacheException(String.format("Unexpected response object type from %s: %s", sender, responseClass));
}
} else if (wasSuspected) {
if (!ignoreLeavers) {
throw new SuspectException("Suspected member: " + sender, sender);
} else {
log.tracef("Target node %s left during remote call, ignoring", sender);
}
} else {
// if we have a response filter then we may not have waited for some nodes!
if (!usedResponseFilter) throw new TimeoutException("Replication timeout for " + sender);
}