@Override public T handleResponse(HttpRequest<?> httpRequest, InputStream is, Integer statusCode, IOException e) throws IOException { // we have to read the whole response, otherwise bad things happen IOUtils.consumeAndClose(is); return null; }
@Override public JsonNode handleResponse(HttpRequest<?> httpRequest, InputStream is, Integer statusCode, IOException e) throws IOException { if (statusCode == 200) { return JsonUtils.getMapper().readTree(is); } else { IOUtils.consumeAndClose(is); return null; } } }
@Override public T handleResponse(HttpRequest<?> httpRequest, InputStream is, Integer statusCode, IOException e) throws IOException { if (statusCode != null && statusCode >= 400) { logger.warn(httpRequest.getSafeUrl() + ": " + statusCode + " " + IOUtils.toString(is)); } else { IOUtils.consumeAndClose(is); } return null; } }
private void onFlushSuccess(InputStream inputStream) { errorCount = 0; reported += currentlyTransmitting; // in order to be able to reuse the underlying TCP connections, // the input stream must be consumed and closed // see also https://docs.oracle.com/javase/8/docs/technotes/guides/net/http-keepalive.html IOUtils.consumeAndClose(inputStream); }
@Override public JsonNode handleResponse(HttpRequest<?> httpRequest, InputStream is, Integer statusCode, IOException e) throws IOException { if (statusCode == 200) { return JsonUtils.getMapper().readTree(is); } else { IOUtils.consumeAndClose(is); return null; } } }
private void onFlushError(Integer responseCode, InputStream inputStream, @Nullable IOException e) { // TODO read accepted, dropped and invalid onConnectionError(responseCode, currentlyTransmitting, 0); if (e != null) { logger.error("Error sending data to APM server: {}, response code is {}", e.getMessage(), responseCode); logger.debug("Sending payload to APM server failed", e); } if (logger.isWarnEnabled()) { try { logger.warn(IOUtils.toString(inputStream)); } catch (IOException e1) { logger.warn(e1.getMessage(), e); } finally { IOUtils.closeQuietly(inputStream); } } else { // in order to be able to reuse the underlying TCP connections, // the input stream must be consumed and closed // see also https://docs.oracle.com/javase/8/docs/technotes/guides/net/http-keepalive.html IOUtils.consumeAndClose(inputStream); } }