protected void handleResponse( Channel channel, StreamInput buffer, final TransportResponseHandler handler) { final TransportResponse response = handler.newInstance(); response.remoteAddress( new InetSocketTransportAddress((InetSocketAddress) channel.getRemoteAddress())); response.remoteAddress(); try { response.readFrom(buffer); } catch (Throwable e) { handleException( handler, new TransportSerializationException( "Failed to deserialize response of type [" + response.getClass().getName() + "]", e)); return; } try { if (handler.executor() == ThreadPool.Names.SAME) { //noinspection unchecked handler.handleResponse(response); } else { threadPool.executor(handler.executor()).execute(new ResponseHandler(handler, response)); } } catch (Throwable e) { handleException(handler, new ResponseHandlerFailureTransportException(e)); } }
protected void handleResponse( StreamInput buffer, LocalTransport sourceTransport, final TransportResponseHandler handler) { buffer = new NamedWriteableAwareStreamInput(buffer, namedWriteableRegistry); final TransportResponse response = handler.newInstance(); response.remoteAddress(sourceTransport.boundAddress.publishAddress()); try { response.readFrom(buffer); } catch (Throwable e) { handleException( handler, new TransportSerializationException( "Failed to deserialize response of type [" + response.getClass().getName() + "]", e)); return; } handleParsedResponse(response, handler); }