-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix request attribute-related race condition in Logback request logging #1678
Fix request attribute-related race condition in Logback request logging #1678
Conversation
It's very strange to step on those thread-safety issues with Logback (or the SLF4J bridge). Let's see if the fix helps, I even don't known how to write a unit to reproduce it. |
event.prepareForDeferredProcessing(); | ||
} | ||
}; | ||
return new AsyncAppenderBase<IAccessEvent>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please also update the Javadoc for this method? In looks a lit bit wrong for me.
- It should link to
AsyncAppenderBase
rather than toAsyncAppenderFactory
(not-related issue to this change) - I think we should remove a claim about deferred processing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely, thanks for mentioning. It would be nice to collapse this and io.dropwizard.logging.async.AsyncLoggingEventAppenderFactory
into a single class parameterized on the type of event, since they're now almost identical. This would be a breaking change, though.
I took the liberty of updating AsyncLoggingEventAppenderFactory
's Javadoc too, since it also incorrectly links to AsyncAppenderFactory
.
Thanks, @evnm! |
Cherry-picked to the 1.0,x branch. |
Addresses #1672
i.d.request.logging.async.AsyncAccessEventAppenderFactory
invokesAccessEvent. prepareForDeferredProcessing
, which triggers a race with an identical invocation within Logback itself. The reported issue indicates that the race manifests in inconsistent logging behavior when request attributes are set within a resource class.This change removes the
prepareForDeferredProcessing
call from dropwizard-request-logging. As far as I know, allIAccessEvent
s encountered by this class will be of concrete typeAccessEvent
and all non-async appenders extendOutputStreamAppender
, so theprepareForDeferredProcessing
method should always be invoked exactly once.