@Override public void sendResponse(Throwable error) throws IOException { BytesStreamOutput stream; try { stream = CachedStreamOutput.cachedBytes(); writeResponseExceptionHeader(stream); RemoteTransportException tx = new RemoteTransportException( targetTransport.nodeName(), targetTransport.boundAddress().boundAddress(), action, error); ThrowableObjectOutputStream too = new ThrowableObjectOutputStream(stream); too.writeObject(tx); too.close(); } catch (NotSerializableException e) { stream = CachedStreamOutput.cachedBytes(); writeResponseExceptionHeader(stream); RemoteTransportException tx = new RemoteTransportException( targetTransport.nodeName(), targetTransport.boundAddress().boundAddress(), action, new NotSerializableTransportException(error)); ThrowableObjectOutputStream too = new ThrowableObjectOutputStream(stream); too.writeObject(tx); too.close(); } final byte[] data = stream.copiedByteArray(); targetTransport .threadPool() .execute( new Runnable() { @Override public void run() { targetTransport.messageReceived(data, action, sourceTransport, null); } }); }