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:
@@ -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
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user