[ 
https://issues.apache.org/jira/browse/LOG4J2-149?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13552924#comment-13552924
 ] 

Scott Severtson commented on LOG4J2-149:
----------------------------------------

Ralph is correct - the patch doesn't actually solve the problem. Sorry for the 
false start.

FYI, I removed the parameter from a few methods to make it more clear what was 
being synchronized on (the SMTPManager.buffer instance variable), versus 
synchronizing on the passed-in variable. I didn't catch that synchronization 
had been moved to the CyclicBuffer itself.

I'll do what I can to create a test app later. However, it's easy to describe 
the problem:
Thread 1: App sends log message #1
Thread 1: Log4J calls isFiltered(message #1) (appends to buffer)
Thread 2: App sends log message #2
Thread 2: Log4J calls isFiltered(message #2) (appends to buffer)
Thread 1: Log4J calls append(message #1) (clears buffer, delivers *both* 
messages)
Thread 2: Log4J calls append(message #2) (empty buffer, delivers no messages)

Any thoughts on a possible approach to preventing the above scenario?
                
> SMTPManager buffer access not synchronized; can result in empty emails
> ----------------------------------------------------------------------
>
>                 Key: LOG4J2-149
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-149
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Appenders
>    Affects Versions: 2.0-beta4
>         Environment: N/A
>            Reporter: Scott Severtson
>         Attachments: SMTPManager-buffer-synchronization.patch
>
>
> If multiple error events are logged against the same SMTPAppender/Manager at 
> the same time, one email will contain both error messages, while the second 
> will be empty (no events).
> The original SMTPAppender patch included synchronization against the 
> CyclicBuffer to prevent such simultaneous access from multiple threads. This 
> appears to have been lost in the merge/refactor. Patch (to follow shortly) 
> re-introduces synchronization against the CyclicBuffer in the narrowest 
> possible scope.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to