You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@activemq.apache.org by GitBox <gi...@apache.org> on 2021/10/13 14:52:34 UTC

[GitHub] [activemq] mattrpav commented on a change in pull request #720: [AMQ-8400] Add synchronization handling around synchronizations to pr…

mattrpav commented on a change in pull request #720:
URL: https://github.com/apache/activemq/pull/720#discussion_r728150454



##########
File path: activemq-broker/src/main/java/org/apache/activemq/transaction/Transaction.java
##########
@@ -226,4 +232,10 @@ public boolean isRollbackOnly() {
         return rollackOnlyCause != null;
     }
 
+    protected ArrayList<Synchronization> getSynchronizationsCopy() {

Review comment:
       > I'm not really a fan of this solution, there's a couple other approaches you could take.
   > 
   > First, If you are going to copy anyways then why not just use a CopyOnWriteArrayList and not have to synchronize and do all the manual copying?
   > 
   > Another option that might be better is just do what JB said and synchronized the list. Then you also need to synchronize when iterating as well and this would avoid the expensive copy as wrapping with with Synchronized doesn't make iterating thread safe. It should be rare for 2 threads to be touching the Transaction object usually so synchronizing should be fine most of the time.
   > 
   > You also may be able to find another collection type that is concurrent that could be used but for list implementations there aren't really any.
   
   Thanks for the quick review. Agree, not in love with a lot of the approach options. I was hoping to thread the needle around not having to synchronize on all operations, but yeah copies are not great either.
   
   Given the iterator-not-synchronized problem seems that synchronized(synchronizations) {} is best approach forward? 




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

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org