From 4af3badbea6fc346d396e49861a1cfa5f0c0585d Mon Sep 17 00:00:00 2001 From: dreis2211 Date: Tue, 28 May 2019 21:32:00 +0200 Subject: [PATCH 1/2] Avoid using deprecated NCSARequestLog See gh-16987 --- ...etManagementChildContextConfiguration.java | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/servlet/ServletManagementChildContextConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/servlet/ServletManagementChildContextConfiguration.java index de9e3d6b69..69dfe379f4 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/servlet/ServletManagementChildContextConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/servlet/ServletManagementChildContextConfiguration.java @@ -22,8 +22,9 @@ import javax.servlet.Filter; import org.apache.catalina.Valve; import org.apache.catalina.valves.AccessLogValve; -import org.eclipse.jetty.server.NCSARequestLog; +import org.eclipse.jetty.server.CustomRequestLog; import org.eclipse.jetty.server.RequestLog; +import org.eclipse.jetty.server.RequestLogWriter; import org.eclipse.jetty.server.Server; import org.springframework.beans.factory.BeanFactory; @@ -194,17 +195,21 @@ class ServletManagementChildContextConfiguration { private void customizeServer(Server server) { RequestLog requestLog = server.getRequestLog(); - if (requestLog != null && requestLog instanceof NCSARequestLog) { - customizeRequestLog((NCSARequestLog) requestLog); + if (requestLog != null && requestLog instanceof CustomRequestLog) { + customizeRequestLog((CustomRequestLog) requestLog); } } - private void customizeRequestLog(NCSARequestLog requestLog) { - String filename = requestLog.getFilename(); - if (StringUtils.hasLength(filename)) { - File file = new File(filename); - file = new File(file.getParentFile(), customizePrefix(file.getName())); - requestLog.setFilename(file.getPath()); + private void customizeRequestLog(CustomRequestLog requestLog) { + if (requestLog.getWriter() instanceof RequestLogWriter) { + RequestLogWriter writer = (RequestLogWriter) requestLog.getWriter(); + String filename = writer.getFileName(); + if (StringUtils.hasLength(filename)) { + File file = new File(filename); + file = new File(file.getParentFile(), + customizePrefix(file.getName())); + writer.setFilename(file.getPath()); + } } } From 14349518c9be58107c76a32af95fdbdeb26154fb Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Sun, 2 Jun 2019 15:04:59 -0700 Subject: [PATCH 2/2] Polish "Avoid using deprecated NCSARequestLog" See gh-16987 --- ...letManagementChildContextConfiguration.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/servlet/ServletManagementChildContextConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/servlet/ServletManagementChildContextConfiguration.java index 69dfe379f4..21e513766f 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/servlet/ServletManagementChildContextConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/servlet/ServletManagementChildContextConfiguration.java @@ -202,14 +202,16 @@ class ServletManagementChildContextConfiguration { private void customizeRequestLog(CustomRequestLog requestLog) { if (requestLog.getWriter() instanceof RequestLogWriter) { - RequestLogWriter writer = (RequestLogWriter) requestLog.getWriter(); - String filename = writer.getFileName(); - if (StringUtils.hasLength(filename)) { - File file = new File(filename); - file = new File(file.getParentFile(), - customizePrefix(file.getName())); - writer.setFilename(file.getPath()); - } + customizeRequestLogWriter((RequestLogWriter) requestLog.getWriter()); + } + } + + private void customizeRequestLogWriter(RequestLogWriter writer) { + String filename = writer.getFileName(); + if (StringUtils.hasLength(filename)) { + File file = new File(filename); + file = new File(file.getParentFile(), customizePrefix(file.getName())); + writer.setFilename(file.getPath()); } }