@Override public Response _apply(Request request) { final Response resp; byte[] response = null; try { response = client.send(translation.serializeRequest(request)); } catch (IOException e) { LOG.debug("Failed to execute remote request: {}", request); // Failed to get a response from the server for the request. throw new RuntimeException(e); } try { resp = translation.parseResponse(response); } catch (IOException e) { LOG.debug("Failed to deserialize reponse to {}. '{}'", request, new String(response, StandardCharsets.UTF_8)); // Not a protobuf that we could parse. throw new RuntimeException(e); } // The server had an error, throw an Exception for that. if (resp instanceof ErrorResponse) { throw ((ErrorResponse) resp).toException(); } return resp; } }
@Override public Response _apply(Request request) { final Response resp; byte[] response = null; try { response = client.send(translation.serializeRequest(request)); } catch (IOException e) { LOG.debug("Failed to execute remote request: {}", request); // Failed to get a response from the server for the request. throw new RuntimeException(e); } try { resp = translation.parseResponse(response); } catch (IOException e) { LOG.debug("Failed to deserialize reponse to {}. '{}'", request, new String(response, StandardCharsets.UTF_8)); // Not a protobuf that we could parse. throw new RuntimeException(e); } // The server had an error, throw an Exception for that. if (resp instanceof ErrorResponse) { throw ((ErrorResponse) resp).toException(); } return resp; } }
@Override public Response _apply(Request request) { final Response resp; try { byte[] response = client.send(translation.serializeRequest(request)); resp = translation.parseResponse(response); } catch (IOException e) { // Not a protobuf that we could parse. throw new RuntimeException(e); } // The server had an error, throw an Exception for that. if (resp instanceof ErrorResponse) { throw ((ErrorResponse) resp).toException(); } return resp; } }
public Response apply(Response response) throws IOException { // Serialize and then re-pare the response return translation.parseResponse(translation.serializeResponse(response)); } }
public Response apply(Response response) throws IOException { // Serialize and then re-pare the response return translation.parseResponse(translation.serializeResponse(response)); } }
public Response apply(Response response) throws IOException { // Serialize and then re-pare the response return translation.parseResponse(translation.serializeResponse(response)); } }
@Override public Response _apply(Request request) { try { // Serialize the request to "send to the server" byte[] serializedRequest = translation.serializeRequest(request); // *some transport would normally happen here* // Fake deserializing that request somewhere else Request request2 = translation.parseRequest(serializedRequest); // Serialize the response from the service to "send to the client" byte[] serializedResponse = translation.serializeResponse(request2.accept(service)); // *some transport would normally happen here* // Deserialize the response on "the client" return translation.parseResponse(serializedResponse); } catch (IOException e) { throw new RuntimeException(e); } } }
resp = translation.parseResponse(response); } catch (IOException e) { LOG.warn("Failed to deserialize reponse to {}. '{}'", request,
@Override public Response _apply(Request request) { try { // Serialize the request to "send to the server" byte[] serializedRequest = translation.serializeRequest(request); // *some transport would normally happen here* // Fake deserializing that request somewhere else Request request2 = translation.parseRequest(serializedRequest); // Serialize the response from the service to "send to the client" byte[] serializedResponse = translation.serializeResponse(request2.accept(service)); // *some transport would normally happen here* // Deserialize the response on "the client" return translation.parseResponse(serializedResponse); } catch (IOException e) { throw new RuntimeException(e); } } }
@Override public Response _apply(Request request) { try { // Serialize the request to "send to the server" byte[] serializedRequest = translation.serializeRequest(request); // *some transport would normally happen here* // Fake deserializing that request somewhere else Request request2 = translation.parseRequest(serializedRequest); // Serialize the response from the service to "send to the client" byte[] serializedResponse = translation.serializeResponse(request2.accept(service)); // *some transport would normally happen here* // Deserialize the response on "the client" return translation.parseResponse(serializedResponse); } catch (IOException e) { throw new RuntimeException(e); } } }