From 603ff4d0ce324985bb39965d5b4262b2a010e203 Mon Sep 17 00:00:00 2001 From: Anuved Verma Date: Tue, 2 Jul 2024 09:15:58 -0700 Subject: [PATCH] fix --- .../lyft/data/proxyserver/ProxyHandler.java | 32 +++++++------------ 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/proxyserver/src/main/java/com/lyft/data/proxyserver/ProxyHandler.java b/proxyserver/src/main/java/com/lyft/data/proxyserver/ProxyHandler.java index bf09b71b..d5ff024d 100644 --- a/proxyserver/src/main/java/com/lyft/data/proxyserver/ProxyHandler.java +++ b/proxyserver/src/main/java/com/lyft/data/proxyserver/ProxyHandler.java @@ -60,7 +60,6 @@ protected void postConnectionHook( request.getRequestURL()); } response.getOutputStream().write(buffer, offset, length); - // [sev-16337] with a 10% probably, log the request and response headers and size for debugging if (Math.random() < 0.10) { log.debug("Request URL: {} , request URI {} , servlet path {} , toString {}, size {}", @@ -73,36 +72,27 @@ protected void postConnectionHook( log.error("Exception occurred while processing request URL: {} , request URI {} ," + " servlet path {} , toString {}, size {}", request.getRequestURL(), request.getRequestURI(), request.getServletPath(), request.toString(), request.getContentLength(), var9); - - String requestHeaderLog = getErrorLogHeaders(request); - log.error(requestHeaderLog); - - String responseHeaderLog = getErrorLogHeaders(response); - log.error(responseHeaderLog); + errorLogHeaders(request); + errorLogHeaders(response); callback.failed(var9); } } - protected String getErrorLogHeaders(HttpServletRequest request) { - StringBuilder sb = new StringBuilder(); - sb.append("------- error HttpServletRequest headers---------\n"); + protected void errorLogHeaders(HttpServletRequest request) { + log.error("------- error HttpServletRequest headers---------"); Enumeration headers = request.getHeaderNames(); while (headers.hasMoreElements()) { String header = headers.nextElement(); - sb.append(header).append("->").append(request.getHeader(header)).append("\n"); + log.error(header + "->" + request.getHeader(header)); } - return sb.toString(); } - protected String getErrorLogHeaders(HttpServletResponse response) { - StringBuilder sb = new StringBuilder(); - sb.append("------- error HttpServletResponse headers---------\n"); - Enumeration headers = response.getHeaderNames(); - while (headers.hasMoreElements()) { - String header = headers.nextElement(); - sb.append(header).append("->").append(response.getHeader(header)).append("\n"); + protected void errorLogHeaders(HttpServletResponse response) { + log.error("------- error HttpServletResponse headers---------"); + Collection headers = response.getHeaderNames(); + for (String header : headers) { + log.error(header + "->" + response.getHeader(header)); } - return sb.toString(); } protected void debugLogHeaders(HttpServletRequest request) { @@ -172,4 +162,4 @@ protected boolean isCompressed(final byte[] compressed) { return (compressed[0] == (byte) (GZIPInputStream.GZIP_MAGIC)) && (compressed[1] == (byte) (GZIPInputStream.GZIP_MAGIC >> 8)); } -} +} \ No newline at end of file