summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSasa Zivkov <sasa.zivkov@sap.com>2012-06-12 15:11:40 +0200
committerSasa Zivkov <sasa.zivkov@sap.com>2012-06-12 15:50:59 +0200
commita36418c0d0fa0d452546f12e20171daaa518ee25 (patch)
tree4fe8c470f84af100e33c9774ea7d1242896f092e
parentc347a0b534d9fef53c2056254ee88da8e4e88b86 (diff)
Make logging events discardable, prevent NPE in AsyncAppender thread.
In rare but possible case when an AsyncAppender-Dispatcher thread tries to discard queued logging events, it throws a NPE and the thread dies. Soon after that, as the async logging queue gets full the threads start blocking on the queue when they try to log something. The NPE was caused by passing null for the logger parameter of LoggingEvent instances created by SshLog and HttpLog. To fix the issue we simply pass the already existing logger instance to the constructor of LoggingEvent. Change-Id: If213a63a80895483b0a32dd4a172cb6ac464ecf7 Signed-off-by: Sasa Zivkov <sasa.zivkov@sap.com>
-rw-r--r--gerrit-pgm/src/main/java/com/google/gerrit/pgm/http/jetty/HttpLog.java2
-rw-r--r--gerrit-sshd/src/main/java/com/google/gerrit/sshd/SshLog.java4
2 files changed, 3 insertions, 3 deletions
diff --git a/gerrit-pgm/src/main/java/com/google/gerrit/pgm/http/jetty/HttpLog.java b/gerrit-pgm/src/main/java/com/google/gerrit/pgm/http/jetty/HttpLog.java
index 65e73bd739..4b773a57f6 100644
--- a/gerrit-pgm/src/main/java/com/google/gerrit/pgm/http/jetty/HttpLog.java
+++ b/gerrit-pgm/src/main/java/com/google/gerrit/pgm/http/jetty/HttpLog.java
@@ -93,7 +93,7 @@ class HttpLog extends AbstractLifeCycle implements RequestLog {
private void doLog(Request req, Response rsp, CurrentUser user) {
final LoggingEvent event = new LoggingEvent( //
Logger.class.getName(), // fqnOfCategoryClass
- null, // logger (optional)
+ log, // logger
System.currentTimeMillis(), // when
Level.INFO, // level
"", // message text
diff --git a/gerrit-sshd/src/main/java/com/google/gerrit/sshd/SshLog.java b/gerrit-sshd/src/main/java/com/google/gerrit/sshd/SshLog.java
index 32d5a076c6..78973928b0 100644
--- a/gerrit-sshd/src/main/java/com/google/gerrit/sshd/SshLog.java
+++ b/gerrit-sshd/src/main/java/com/google/gerrit/sshd/SshLog.java
@@ -99,7 +99,7 @@ class SshLog implements LifecycleListener {
void onAuthFail(final SshSession sd) {
final LoggingEvent event = new LoggingEvent( //
Logger.class.getName(), // fqnOfCategoryClass
- null, // logger (optional)
+ log, // logger
System.currentTimeMillis(), // when
Level.INFO, // level
"AUTH FAILURE FROM " + sd.getRemoteAddressAsString(), // message text
@@ -168,7 +168,7 @@ class SshLog implements LifecycleListener {
final LoggingEvent event = new LoggingEvent( //
Logger.class.getName(), // fqnOfCategoryClass
- null, // logger (optional)
+ log, // logger
System.currentTimeMillis(), // when
Level.INFO, // level
msg, // message text