protected boolean parseResponseAndAddToResponseList(Object responseObject, List<Response> responseListToAddTo, boolean wasSuspected,
boolean wasReceived, Address sender, boolean usedResponseFilter)
throws Exception
{
Log log = getLog();
boolean trace = log.isTraceEnabled();
boolean invalidResponse = true;
if (wasSuspected || !wasReceived) {
if (wasSuspected) {
throw new SuspectException("Suspected member: " + 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);
}
} else {
invalidResponse = false;
if (responseObject instanceof Response) {
Response response = (Response) responseObject;
if (response instanceof ExceptionResponse) {
Exception e = ((ExceptionResponse) response).getException();
if (!(e instanceof ReplicationException)) {
// 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 {0}", sender, e);
}
}
}
responseListToAddTo.add(response);
} else if (responseObject instanceof Exception) {
Exception e = (Exception) responseObject;
if (trace) log.trace("Unexpected exception from " + sender, e);
throw e;
} else if (responseObject instanceof Throwable) {
Throwable t = (Throwable) responseObject;
if (trace) log.trace("Unexpected throwable from " + sender, t);
throw new CacheException("Remote (" + sender + ") failed unexpectedly", t);
}
}
return invalidResponse;