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>
This commit is contained in:
Sasa Zivkov
2012-06-12 15:11:40 +02:00
parent c347a0b534
commit a36418c0d0
2 changed files with 3 additions and 3 deletions

View File

@@ -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

View File

@@ -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