Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
anuvedverma committed Jul 2, 2024
1 parent e781b3f commit 603ff4d
Showing 1 changed file with 11 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}",
Expand All @@ -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<String> 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<String> 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<String> headers = response.getHeaderNames();
for (String header : headers) {
log.error(header + "->" + response.getHeader(header));
}
return sb.toString();
}

protected void debugLogHeaders(HttpServletRequest request) {
Expand Down Expand Up @@ -172,4 +162,4 @@ protected boolean isCompressed(final byte[] compressed) {
return (compressed[0] == (byte) (GZIPInputStream.GZIP_MAGIC))
&& (compressed[1] == (byte) (GZIPInputStream.GZIP_MAGIC >> 8));
}
}
}

0 comments on commit 603ff4d

Please sign in to comment.