diff --git a/core/src/main/java/com/flipkart/gjex/core/filter/http/AccessLogHttpFilter.java b/core/src/main/java/com/flipkart/gjex/core/filter/http/AccessLogHttpFilter.java index 5de28c7c..c4da84b9 100644 --- a/core/src/main/java/com/flipkart/gjex/core/filter/http/AccessLogHttpFilter.java +++ b/core/src/main/java/com/flipkart/gjex/core/filter/http/AccessLogHttpFilter.java @@ -10,6 +10,7 @@ import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletResponse; import java.util.Map; +import java.util.Optional; /** * Implements an HTTP filter for logging access requests. This filter captures and logs @@ -81,8 +82,9 @@ public void doProcessResponse(ServletResponse response) { HttpServletResponse httpServletResponse = (HttpServletResponse) response; if (isSuccess(httpServletResponse.getStatus())) { // 2xx response - accessLogContextBuilder.contentLength(Integer.valueOf(httpServletResponse - .getHeader(HttpHeaderNames.CONTENT_LENGTH.toString()))); + int contentLength = Optional.ofNullable(httpServletResponse.getHeader(HttpHeaderNames.CONTENT_LENGTH.toString())) + .map(Integer::parseInt).orElse(0); + accessLogContextBuilder.contentLength(contentLength); } else { // non-2xx response accessLogContextBuilder.contentLength(0);