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

Sebb commented on LOGGING-135:
------------------------------

If thread A creates the class and passes it to thread B (which already exists) 
there is no guarantee that thread B will see the same value as written by 
thread A (this is a consequence of the Java memory model, which allows for lots 
of hardware optimisations).

Furthermore, the field is protected, so it can be changed at any later time. 
Unless the writer and reader threads synchronise on the same lock (or the field 
is made volatile), there is no guarantee that thread B will see what thread A 
wrote.
                
> Thread-safety improvements
> --------------------------
>
>                 Key: LOGGING-135
>                 URL: https://issues.apache.org/jira/browse/LOGGING-135
>             Project: Commons Logging
>          Issue Type: Bug
>            Reporter: Sebb
>
> The LogKitLogger.logger field is not final or volatile so changes are not 
> guaranteed to be published.
> This includes calls to getLogger(), so two different threads using the same 
> instance can theoretically both create the logger.

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

Reply via email to