Source:
<code>public void enqueue(Callback callback) { super.enqueue(new Callback() { @Override public void onFailure(Call call, IOException exception) { if (!backoffStrategy.nextBackoff().isPresent()) { callback.onFailure(call, new IOException("Failed to complete the request due to an " + "IOException", exception)); return; } Optional<HttpUrl> redirectTo = urls.redirectToNext(request().url()); if (!redirectTo.isPresent()) { callback.onFailure(call, new IOException("Failed to determine valid failover URL" + "for '" + request().url() + "' and base URLs " + urls.getBaseUrls())); return; } Request redirectedRequest = request().newBuilder() .url(redirectTo.get()) .build(); RemotingOkHttpCall retryCall = client.newCallWithMutableState(redirectedRequest, backoffStrategy, maxNumRelocations - 1); retryCall.enqueue(callback); } @Override public void onResponse(Call call, Response response) throws IOException { if (response.code() / 100 <= 2) { callback.onResponse(call, response); return; } <START> byte[] bodyBytes; <END> try { bodyBytes = response.body().bytes(); } catch (IOException e) { onFailure(call, e); return; } Optional<QosException> qosError = qosHandler.handle(buildFrom(response, bodyBytes)); if (qosError.isPresent()) { qosError.get().accept(createQosVisitor(callback, call)); return; } Optional<RemoteException> httpError = remoteExceptionHandler.handle(buildFrom(response, bodyBytes)); if (httpError.isPresent()) { callback.onFailure(call, new IoRemoteException(httpError.get())); return; } Optional<IOException> ioException = ioExceptionHandler.handle(buildFrom(response, bodyBytes)); if (ioException.isPresent()) { callback.onFailure(call, ioException.get()); return; } callback.onFailure(call, new IOException("Failed to handle request, this is an http-remoting bug.")); } }); }</code><technical_language>instead of forcing downstreams deal notion of response body, Supplier<Response> errorResponseSupplier; try { byte[] body = response.body().bytes(); // error handlers read body breaking subsequent handlers errorResponseSupplier = () -> buildFrom(response, bodyBytes); } ? errorResponseSupplier.get()</technical_language>

Target:
public void enqueue(Callback callback) { super.enqueue(new Callback() { @Override public void onFailure(Call call, IOException exception) { if (!backoffStrategy.nextBackoff().isPresent()) { callback.onFailure(call, new IOException("Failed to complete the request due to an " + "IOException", exception)); return; } Optional<HttpUrl> redirectTo = urls.redirectToNext(request().url()); if (!redirectTo.isPresent()) { callback.onFailure(call, new IOException("Failed to determine valid failover URL" + "for '" + request().url() + "' and base URLs " + urls.getBaseUrls())); return; } Request redirectedRequest = request().newBuilder() .url(redirectTo.get()) .build(); RemotingOkHttpCall retryCall = client.newCallWithMutableState(redirectedRequest, backoffStrategy, maxNumRelocations - 1); retryCall.enqueue(callback); } @Override public void onResponse(Call call, Response response) throws IOException { if (response.code() / 100 <= 2) { callback.onResponse(call, response); return; } Supplier<Response> errorResponseSupplier; try { byte[] body = response.body().bytes(); errorResponseSupplier = () -> buildFrom(response, body); } catch (IOException e) { onFailure(call, e); return; } Optional<QosException> qosError = qosHandler.handle(errorResponseSupplier.get()); if (qosError.isPresent()) { qosError.get().accept(createQosVisitor(callback, call)); return; } Optional<RemoteException> httpError = remoteExceptionHandler.handle(errorResponseSupplier.get()); if (httpError.isPresent()) { callback.onFailure(call, new IoRemoteException(httpError.get())); return; } Optional<IOException> ioException = ioExceptionHandler.handle(errorResponseSupplier.get()); if (ioException.isPresent()) { callback.onFailure(call, ioException.get()); return; } callback.onFailure(call, new IOException("Failed to handle request, this is an http-remoting bug.")); } }); }