gemmellr commented on code in PR #4407:
URL: https://github.com/apache/activemq-artemis/pull/4407#discussion_r1140321560


##########
artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ActiveMQTestBase.java:
##########
@@ -235,29 +222,40 @@ public MBeanServer getMBeanServer() {
    // There is a verification about thread leakages. We only fail a single 
thread when this happens
    private static Set<Thread> alreadyFailedThread = new HashSet<>();
 
-   private LinkedList<RunnableEx> runAfter;
+   private volatile List<RunnableEx> runAfter;
 
    protected synchronized void runAfter(RunnableEx run) {
       Assert.assertNotNull(run);
       if (runAfter == null) {
-         runAfter = new LinkedList();
+         runAfter = Collections.synchronizedList(new ArrayList<>());
       }
       runAfter.add(run);
    }
 
    @After
    public void runAfter() {
-      if (runAfter != null) {
-         runAfter.forEach((r) -> {
+      List<RunnableEx> theRunafterList = runAfter;
+      if (theRunafterList != null) {
+         // I do this replacement as eventually a runAfter lambda could be 
adding another runAfter.
+         // this shouldn't happen very often but I saw it happening once.
+         // it's better to be protected against

Review Comment:
   AH! So I resisted the temptation to comment when passing that getter that I 
really didnt like the method resulting in scheduling stuff.  But I totally 
overloooked that was this issue. lol.
   
   That seals it, I really dont think that URI getter should be doing that, 
something else should be specifically opening the DB, which calls the URI 
getter.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to