if (magic != HotRodConstants.RESPONSE_MAGIC) {
String message = "Invalid magic number. Expected %#x and received %#x";
localLog.invalidMagicNumber(HotRodConstants.RESPONSE_MAGIC, magic);
if (isTrace)
localLog.tracef("Socket dump: %s", hexDump(transport.dumpStream()));
throw new InvalidResponseException(String.format(message, HotRodConstants.RESPONSE_MAGIC, magic));
}
long receivedMessageId = transport.readVLong();
// If received id is 0, it could be that a failure was noted before the
// message id was detected, so don't consider it to a message id error
if (receivedMessageId != params.messageId && receivedMessageId != 0) {
String message = "Invalid message id. Expected %d and received %d";
localLog.invalidMessageId(params.messageId, receivedMessageId);
if (isTrace)
localLog.tracef("Socket dump: %s", hexDump(transport.dumpStream()));
throw new InvalidResponseException(String.format(message, params.messageId, receivedMessageId));
}
localLog.tracef("Received response for message id: %d", receivedMessageId);
short receivedOpCode = transport.readByte();
// Read both the status and new topology (if present),
// before deciding how to react to error situations.
short status = transport.readByte();
readNewTopologyIfPresent(transport, params);
// Now that all headers values have been read, check the error responses.
// This avoids situatiations where an exceptional return ends up with
// the socket containing data from previous request responses.
if (receivedOpCode != params.opRespCode) {
if (receivedOpCode == HotRodConstants.ERROR_RESPONSE) {
checkForErrorsInResponseStatus(transport, params, status);
}
throw new InvalidResponseException(String.format(
"Invalid response operation. Expected %#x and received %#x",
params.opRespCode, receivedOpCode));
}
localLog.tracef("Received operation code is: %#04x", receivedOpCode);