@Override public Object sendAndReceive(ClientRequest request, ClientConnection connection) throws Exception { final SerializationService ss = client.getSerializationService(); connection.write(ss.toData(request)); final Data data = connection.read(); ClientResponse clientResponse = ss.toObject(data); Object response = ss.toObject(clientResponse.getResponse()); if (response instanceof Throwable) { Throwable t = (Throwable) response; ExceptionUtil.fixRemoteStackTrace(t, Thread.currentThread().getStackTrace()); throw new Exception(t); } return response; }
private boolean writeToConnection(ClientConnection connection, ClientMessage clientMessage) { clientMessage.addFlag(ClientMessage.BEGIN_AND_END_FLAGS); return connection.write(clientMessage); }