This is an automated email from the ASF dual-hosted git repository.
jbonofre pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq.git
The following commit(s) were added to refs/heads/main by this push:
new e505a9b617 Refactor AMQ3529v2Test to improve thread handling and
logging consistency (#1649)
e505a9b617 is described below
commit e505a9b61704208c063807bf73e81098e03e14c0
Author: Jean-Louis Monteiro <[email protected]>
AuthorDate: Tue Feb 17 17:07:59 2026 +0100
Refactor AMQ3529v2Test to improve thread handling and logging consistency
(#1649)
---
.../org/apache/activemq/bugs/AMQ3529v2Test.java | 57 ++++++++++++++--------
1 file changed, 38 insertions(+), 19 deletions(-)
diff --git
a/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3529v2Test.java
b/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3529v2Test.java
index 6de2b90a57..45b9c7c697 100644
---
a/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3529v2Test.java
+++
b/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3529v2Test.java
@@ -177,18 +177,15 @@ public class AMQ3529v2Test {
thread.start();
}
// interrupt the threads at some random time
- ExecutorService doTheInterrupts =
Executors.newFixedThreadPool(threads.size());
+ final ExecutorService doTheInterrupts =
Executors.newFixedThreadPool(threads.size());
for (final Thread thread : threads) {
- doTheInterrupts.execute(new Runnable() {
- @Override
- public void run() {
- try {
- Thread.sleep(random.nextInt(5000));
- } catch (InterruptedException ignored) {
- ignored.printStackTrace();
- }
- thread.interrupt();
+ doTheInterrupts.execute(() -> {
+ try {
+ Thread.sleep(random.nextInt(5000));
+ } catch (InterruptedException ignored) {
+ ignored.printStackTrace();
}
+ thread.interrupt();
});
}
doTheInterrupts.shutdown();
@@ -200,21 +197,43 @@ public class AMQ3529v2Test {
for (ClientThread thread : threads) {
if (thread.error != null) {
- LOG.info("Close error on thread: " + thread, thread.error);
+ LOG.info("Close error on thread: {}", thread, thread.error);
}
}
- Thread[] remainThreads = new Thread[tg.activeCount()];
+ final Thread[] remainThreads = new Thread[tg.activeCount()];
tg.enumerate(remainThreads);
+ final List<Thread> transportThreads = new LinkedList<>();
for (final Thread t : remainThreads) {
- if (t != null && t.isAlive() && !t.isDaemon())
- assertTrue("Thread completes:" + t, Wait.waitFor(new
Wait.Condition() {
- @Override
- public boolean isSatisified() throws Exception {
- LOG.info("Remaining thread: " + t.toString());
- return !t.isAlive();
+ if (t == null || !t.isAlive() || t.isDaemon()) {
+ continue;
+ }
+ if (t.getName().startsWith("ActiveMQ Transport")) {
+ transportThreads.add(t);
+ continue;
+ }
+ assertTrue("Thread completes:" + t, Wait.waitFor(() -> {
+ LOG.info("Remaining thread: {}", t.toString());
+ return !t.isAlive();
+ }));
+ }
+ if (!transportThreads.isEmpty()) {
+ final ExecutorService transportWait =
Executors.newFixedThreadPool(transportThreads.size());
+ for (final Thread t : transportThreads) {
+ transportWait.execute(() -> {
+ try {
+ t.join(TimeUnit.SECONDS.toMillis(45));
+ } catch (InterruptedException ignored) {
}
- }));
+ });
+ }
+ transportWait.shutdown();
+ transportWait.awaitTermination(60, TimeUnit.SECONDS);
+ for (final Thread t : transportThreads) {
+ if (t.isAlive()) {
+ LOG.warn("Transport thread still running after wait: {}",
t);
+ }
+ }
}
ThreadGroup root = Thread.currentThread().getThreadGroup().getParent();
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact