You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomee.apache.org by GitBox <gi...@apache.org> on 2019/06/10 10:28:21 UTC

[GitHub] [tomee] doychin commented on issue #485: Use ListOrderedSet for thread context listeners.

doychin commented on issue #485: Use ListOrderedSet for thread context listeners.
URL: https://github.com/apache/tomee/pull/485#issuecomment-500368987
 
 
   Few months a go it was CopyOnWriteArrayList. Then I found that using list for this purpose does not work because there is no way to protect that list from ending with multiple instances of the same listener or some listeners were never removed from the collection even when they are not needed anymore. 
   
   This happens in some test cases where tests are run one after another in the same VM and test start depending on the order of execution - the presence of a listener breaks a test.
   
   So this structure must be kept in a state that is predictable. That's why I changed it to Set using CopyOnWriteArraySet. 
   
   Few days a go @dblevins reverted my change because for some odd reason there is some CXF code that somehow depends on the order of execution of the listeners in this collection. Set's can't guarantee predictable order of execution. 
   
   So we need a solution that guarantees both - same order of execution based on the order of add/remove from the collection and no more then one instance of a listener in the collection. 
   
   In this case none of the listeners implements equals and hash code. I made sure that those listeners that are never removed from the list are initialized only once so same instance is "added" every time.
   
   The rest are removed during undeploy/stop of the container.
   
   I could use ListOrderedSet from collections 3 but it is not generic so I added v4 of collections to the mix which is already used by openjpa so it is not new dependency.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services