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

Ioan Eugen Stan commented on IMAP-372:
--------------------------------------

Hi, 

Disclaimer: I don't have time yet to look at this. Don't take my advice the 
wrong way, but:  As a general rule to avoid threading issues I prefer to use 
immutable objects as much as possible. Guava provides a lot of useful methods 
to deal with immutable collections [3]. 

Cheers, 

[1] http://docs.oracle.com/javase/tutorial/essential/concurrency/immutable.html 
[2] http://docs.oracle.com/javase/tutorial/essential/concurrency/imstrat.html
[3] http://code.google.com/p/guava-libraries/wiki/ImmutableCollectionsExplained

                
> Deadlock in AbstractDelegatingMailboxListener under load
> --------------------------------------------------------
>
>                 Key: IMAP-372
>                 URL: https://issues.apache.org/jira/browse/IMAP-372
>             Project: James Imap
>          Issue Type: Bug
>          Components: Mailbox
>            Reporter: Andrzej Rusin
>            Assignee: Eric Charles
>         Attachments: James Listener Deadlock.txt
>
>
> In AbstractDelegatingMailboxListener::event, firing the events inside the 
> synchronized blocks causes a deadlock involving:
> lock on HashMapDelegatingMailboxListener::listeners
> (synchronized methods) lock on SelectedMailboxImpl
> In my example, these 3 methods got interlocked:
> AbstractDelegatingMailboxListener.addListener
> SelectedMailboxImpl.msn
> AbstractDelegatingMailboxListener.removeListener
> My idea to fix it is basically to take the for loop on mListeners outside the 
> synchronized block in 
> org.apache.james.mailbox.store.AbstractDelegatingMailboxListener.event(Event).
>  That will not make the propagated event processing in SelectedMailboxImpl 
> hit the synchronized lock on listeners.

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