This is an automated email from the ASF dual-hosted git repository.
adutra pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/polaris.git
The following commit(s) were added to refs/heads/main by this push:
new 1698e5c6 Fix ManifestFileCleanupTaskHandlerTest.testCleanupWithRetries
(#576)
1698e5c6 is described below
commit 1698e5c6ea9d68dc7e7d0baf9011a0425550f3af
Author: Alexandre Dutra <[email protected]>
AuthorDate: Thu Dec 26 12:43:46 2024 +0100
Fix ManifestFileCleanupTaskHandlerTest.testCleanupWithRetries (#576)
This test wrongly assumes that the ForkJoin Pool thread
that will execute the async task will be a new one, and that
it will inherit the thread locals from its parent, including
CallContext. But that is not guaranteed.
---
.../task/ManifestFileCleanupTaskHandlerTest.java | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git
a/dropwizard/service/src/test/java/org/apache/polaris/service/dropwizard/task/ManifestFileCleanupTaskHandlerTest.java
b/dropwizard/service/src/test/java/org/apache/polaris/service/dropwizard/task/ManifestFileCleanupTaskHandlerTest.java
index 3a90e706..b594b8e0 100644
---
a/dropwizard/service/src/test/java/org/apache/polaris/service/dropwizard/task/ManifestFileCleanupTaskHandlerTest.java
+++
b/dropwizard/service/src/test/java/org/apache/polaris/service/dropwizard/task/ManifestFileCleanupTaskHandlerTest.java
@@ -28,6 +28,7 @@ import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Stream;
@@ -441,15 +442,18 @@ class ManifestFileCleanupTaskHandlerTest {
.setName(UUID.randomUUID().toString())
.build();
- CompletableFuture<Void> future =
- CompletableFuture.runAsync(
- () -> {
- assertThatPredicate(handler::canHandleTask).accepts(task);
- handler.handleTask(task); // this will schedule the batch
deletion
- });
-
- // Wait for all async tasks to finish
- future.join();
+ try (ExecutorService executor = Executors.newSingleThreadExecutor()) {
+ CompletableFuture<Void> future;
+ future =
+ CompletableFuture.runAsync(
+ () -> {
+ assertThatPredicate(handler::canHandleTask).accepts(task);
+ handler.handleTask(task); // this will schedule the batch
deletion
+ },
+ executor);
+ // Wait for all async tasks to finish
+ future.join();
+ }
// Check if the file was successfully deleted after retries
assertThat(TaskUtils.exists(statisticsFile.path(), fileIO)).isFalse();