From fcbd29b7f926e9c1c4775afec7ae1aded94ac8bb Mon Sep 17 00:00:00 2001 From: JCgH4164838Gh792C124B5 <43964333+JCgH4164838Gh792C124B5@users.noreply.github.com> Date: Tue, 17 Sep 2019 21:10:34 -0400 Subject: [PATCH] Changed the log outputs in this PR to utilize log4j2 {} notation (as per suggestion by A. Mashchenko and L. Lenart) Changed the log outputs in this PR from info level to warn level (as per suggestion by L. Lenart). Note: The info level was originally chosen to make it easier to filter out in the very unlikely case of log flood. --- .../struts2/dispatcher/DefaultDispatcherErrorHandler.java | 8 ++++---- .../struts2/dispatcher/DefaultStaticContentLoader.java | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/org/apache/struts2/dispatcher/DefaultDispatcherErrorHandler.java b/core/src/main/java/org/apache/struts2/dispatcher/DefaultDispatcherErrorHandler.java index 4e2af85da..5f1fd2272 100644 --- a/core/src/main/java/org/apache/struts2/dispatcher/DefaultDispatcherErrorHandler.java +++ b/core/src/main/java/org/apache/struts2/dispatcher/DefaultDispatcherErrorHandler.java @@ -97,10 +97,10 @@ public class DefaultDispatcherErrorHandler implements DispatcherErrorHandler { response.sendError(code, e.getMessage()); } catch (IOException e1) { // we're already sending an error, not much else we can do if more stuff breaks - LOG.info("Unable to send error response, code: " + code + "! (IOException): " + e1); + LOG.warn("Unable to send error response, code: {}! (IOException): {}", code, e1.toString()); } catch (IllegalStateException ise) { // Log illegalstate instead of passing unrecoverable exception to calling thread - LOG.info("Unable to send error response, code: " + code + "! isCommited: " + response.isCommitted() + " (IllegalStateException): " + ise); + LOG.warn("Unable to send error response, code: {}! isCommited: {}. (IllegalStateException): {}", code, response.isCommitted(), ise.toString()); } } @@ -126,10 +126,10 @@ public class DefaultDispatcherErrorHandler implements DispatcherErrorHandler { response.sendError(code, "Unable to show problem report:\n" + exp + "\n\n" + LocationUtils.getLocation(exp)); } catch (IOException ex) { // we're already sending an error, not much else we can do if more stuff breaks - LOG.info("Unable to send error response, code: " + code + "! (IOException): ", ex); // Stacktrace with DevMode + LOG.warn("Unable to send error response, code: {}! (IOException): {}", code, ex); // Stacktrace with DevMode } catch (IllegalStateException ise) { // Log illegalstate instead of passing unrecoverable exception to calling thread - LOG.info("Unable to send error response, code: " + code + "! isCommited: " + response.isCommitted() + " (IllegalStateException): ", ise); // Stacktrace with DevMode + LOG.warn("Unable to send error response, code: {}! isCommited: {}. (IllegalStateException): {}", code, response.isCommitted(), ise); // Stacktrace with DevMode } } } diff --git a/core/src/main/java/org/apache/struts2/dispatcher/DefaultStaticContentLoader.java b/core/src/main/java/org/apache/struts2/dispatcher/DefaultStaticContentLoader.java index 05a5f1b33..79c417918 100644 --- a/core/src/main/java/org/apache/struts2/dispatcher/DefaultStaticContentLoader.java +++ b/core/src/main/java/org/apache/struts2/dispatcher/DefaultStaticContentLoader.java @@ -222,10 +222,10 @@ public class DefaultStaticContentLoader implements StaticContentLoader { response.sendError(HttpServletResponse.SC_NOT_FOUND); } catch (IOException e1) { // we're already sending an error, not much else we can do if more stuff breaks - LOG.info("Unable to send error response, code: " + HttpServletResponse.SC_NOT_FOUND + "! (IOException): " + e1); + LOG.warn("Unable to send error response, code: {}! (IOException): {}", HttpServletResponse.SC_NOT_FOUND, e1.toString()); } catch (IllegalStateException ise) { // Log illegalstate instead of passing unrecoverable exception to calling thread - LOG.info("Unable to send error response, code: " + HttpServletResponse.SC_NOT_FOUND + "! isCommited: " + response.isCommitted() + " (IllegalStateException): " + ise); + LOG.warn("Unable to send error response, code: {}! isCommited: {}. (IllegalStateException): {}", HttpServletResponse.SC_NOT_FOUND, response.isCommitted(), ise.toString()); } }