From e92cef5abcbf6989e8ce58093b34b3ed909da4b8 Mon Sep 17 00:00:00 2001 From: James Moger Date: Mon, 30 Dec 2013 13:51:53 -0500 Subject: [PATCH] Do not serialize the Logger instance Change-Id: Icbef95e95d05fa8d7dbdc750241252d291083820 --- .../com/gitblit/wicket/pages/BasePage.java | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/gitblit/wicket/pages/BasePage.java b/src/main/java/com/gitblit/wicket/pages/BasePage.java index 647a9388..ec84df65 100644 --- a/src/main/java/com/gitblit/wicket/pages/BasePage.java +++ b/src/main/java/com/gitblit/wicket/pages/BasePage.java @@ -65,22 +65,27 @@ import com.gitblit.wicket.WicketUtils; public abstract class BasePage extends SessionPage { - private final Logger logger; + private transient Logger logger; private transient TimeUtils timeUtils; public BasePage() { super(); - logger = LoggerFactory.getLogger(getClass()); customizeHeader(); } public BasePage(PageParameters params) { super(params); - logger = LoggerFactory.getLogger(getClass()); customizeHeader(); } + protected Logger logger() { + if (logger == null) { + logger = LoggerFactory.getLogger(getClass()); + } + return logger; + } + private void customizeHeader() { if (app().settings().getBoolean(Keys.web.useResponsiveLayout, true)) { add(CSSPackageResource.getHeaderContribution("bootstrap/css/bootstrap-responsive.css")); @@ -171,7 +176,7 @@ public abstract class BasePage extends SessionPage { case NONE: break; default: - logger.warn(getClass().getSimpleName() + ": unhandled LastModified type " + cacheControl.value()); + logger().warn(getClass().getSimpleName() + ": unhandled LastModified type " + cacheControl.value()); break; } } @@ -411,7 +416,7 @@ public abstract class BasePage extends SessionPage { } public void warn(String message, Throwable t) { - logger.warn(message, t); + logger().warn(message, t); } public void error(String message, boolean redirect) { @@ -428,9 +433,9 @@ public abstract class BasePage extends SessionPage { public void error(String message, Throwable t, Class toPage, PageParameters params) { if (t == null) { - logger.error(message + " for " + GitBlitWebSession.get().getUsername()); + logger().error(message + " for " + GitBlitWebSession.get().getUsername()); } else { - logger.error(message + " for " + GitBlitWebSession.get().getUsername(), t); + logger().error(message + " for " + GitBlitWebSession.get().getUsername(), t); } if (toPage != null) { GitBlitWebSession.get().cacheErrorMessage(message); @@ -443,7 +448,7 @@ public abstract class BasePage extends SessionPage { } public void authenticationError(String message) { - logger.error(getRequest().getURL() + " for " + GitBlitWebSession.get().getUsername()); + logger().error(getRequest().getURL() + " for " + GitBlitWebSession.get().getUsername()); if (!GitBlitWebSession.get().isLoggedIn()) { // cache the request if we have not authenticated. // the request will continue after authentication. -- 2.39.5