Skip to content

Commit

Permalink
[hotfix][test] Changes the way the thread name of the ComponentMainTh…
Browse files Browse the repository at this point in the history
…readExecutorServiceAdapter is created

The old implementation generated thread names having the prefix multiple times.
  • Loading branch information
XComp committed Sep 23, 2024
1 parent b14ab76 commit e583898
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,13 @@ public static ComponentMainThreadExecutor forSingleThreadExecutor(
@Nonnull ScheduledExecutorService singleThreadExecutor) {
final Thread thread =
CompletableFuture.supplyAsync(Thread::currentThread, singleThreadExecutor).join();
thread.setName(String.format("ComponentMainThread-%s", thread.getName()));
final String testMainThreadNamePrefix = "ComponentMainThread";
if (!thread.getName().contains(testMainThreadNamePrefix)) {
// we have to check the current name first because this instance can be reused as a
// ScheduledExecutorService
thread.setName(String.format("%s-%s", testMainThreadNamePrefix, thread.getName()));
}

return new ComponentMainThreadExecutorServiceAdapter(singleThreadExecutor, thread);
}

Expand Down

0 comments on commit e583898

Please sign in to comment.