}
@Override
public void sendResponse(Object obj) {
long callId = remotePropagatable.getCallId();
Connection conn = remotePropagatable.getConnection();
if (!sent.compareAndSet(false, true) && !(obj instanceof Throwable)) {
throw new ResponseAlreadySentException("NormalResponse already sent for call: " + callId
+ " to " + conn.getEndPoint() + ", current-response: " + obj);
}
NormalResponse response;
if (!(obj instanceof NormalResponse)) {
response = new NormalResponse(obj, remotePropagatable.getCallId(), 0, remotePropagatable.isUrgent());
} else {
response = (NormalResponse) obj;
}
OperationService operationService = nodeEngine.getOperationService();
if (!operationService.send(response, remotePropagatable.getCallerAddress())) {
throw new HazelcastException("Cannot send response: " + obj + " to " + conn.getEndPoint());
}
}