logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mariano Gonzalez <mariano.l.gonza...@gmail.com>
Subject Re: Race condition stopping context
Date Fri, 19 Dec 2014 18:41:48 GMT
Hello,

I've been taking a look at LoggerContext#stop() and for what I see there's
code to prevent disruptor to take new messages but there's nothing making
sure that the ring buffer is empty before actually closing up.

I did a simple test with an Appender wrapper like this:

final class StopConditionSafeAppenderWrapper extends BaseAppenderWrapper
{
    private final LoggerContext loggerContext;

    StopConditionSafeAppenderWrapper(Appender delegate, LoggerContext
loggerContext)
    {
        super(delegate);
        this.loggerContext = loggerContext;
    }

    @Override
    public void append(LogEvent event)
    {
        if (!loggerContext.isStarted()) {
             return;
        }

        super.append(event);
    }
}

Using this appender wrapper I still get the same error, because at the time
that append was closed the context was started but by the time disruptor
processed it it was already stopped (this I could verify with a debugger).

Should I open a bug? Any workaround you could suggest?

Thanks!

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message