Source:
private <T extends Response> T send(String namespace, Request message, String destinationId, Class<T> responseClass) throws IOException { if (isClosed()) { try { connect(); } catch (GeneralSecurityException gse) { throw new ChromeCastException("Unexpected security exception", gse); } } Long requestId = requestCounter.getAndIncrement(); message.setRequestId(requestId); if (!requestId.equals(message.getRequestId())) { throw new IllegalStateException("Request Id getter/setter contract violation"); } if (responseClass == null) { write(namespace, message, destinationId); return null; } ResultProcessor<T> rp = new ResultProcessor<T>(responseClass); requests.put(requestId, rp); write(namespace, message, destinationId); try { T response = rp.get(); if (response instanceof StandardResponse.Invalid) { StandardResponse.Invalid invalid = (StandardResponse.Invalid) response; throw new ChromeCastException("Invalid request: " + invalid.reason); } else if (response instanceof StandardResponse.LoadCancelled || response instanceof StandardResponse.LoadFailed) { throw new ChromeCastException("Unable to load media"); } else if (response instanceof StandardResponse.LaunchError) { StandardResponse.LaunchError launchError = (StandardResponse.LaunchError) response; throw new ChromeCastException("Application launch error: " + launchError.reason); } return response; } catch (InterruptedException e) { throw new ChromeCastException("Interrupted while waiting for response", e); } catch (TimeoutException e) { throw new ChromeCastException("Waiting for response timed out", e); } finally { requests.remove(requestId); } }

Target:
private <T extends Response> T send(String namespace, Request message, String destinationId, Class<T> responseClass) throws IOException { if (isClosed()) { try { connect(); } catch (GeneralSecurityException gse) { throw new ChromeCastException("Unexpected security exception", gse); } } Long requestId = requestCounter.getAndIncrement(); message.setRequestId(requestId); if (!requestId.equals(message.getRequestId())) { throw new IllegalStateException("Request Id getter/setter contract violation"); } if (responseClass == null) { write(namespace, message, destinationId); return null; } ResultProcessor<T> rp = new ResultProcessor<T>(responseClass); requests.put(requestId, rp); write(namespace, message, destinationId); try { T response = rp.get(); if (response instanceof StandardResponse.Invalid) { StandardResponse.Invalid invalid = (StandardResponse.Invalid) response; throw new ChromeCastException("Invalid request: " + invalid.reason); } else if (response instanceof StandardResponse.LoadCancelled) { throw new ChromeCastException("Unable to load media: Load cancelled"); } else if (response instanceof StandardResponse.LoadFailed) { throw new ChromeCastException("Unable to load media: Load failed"); } else if (response instanceof StandardResponse.LaunchError) { StandardResponse.LaunchError launchError = (StandardResponse.LaunchError) response; throw new ChromeCastException("Application launch error: " + launchError.reason); } return response; } catch (InterruptedException e) { throw new ChromeCastException("Interrupted while waiting for response", e); } catch (TimeoutException e) { throw new ChromeCastException("Waiting for response timed out", e); } finally { requests.remove(requestId); } }