From dceebc1c8da4464f627c248b3f0e9f2ad604ed5d Mon Sep 17 00:00:00 2001 From: Chris Eager Date: Fri, 3 Sep 2021 11:58:27 -0700 Subject: [PATCH] =?UTF-8?q?Consistently=20use=20`whenCompleteAsync(?= =?UTF-8?q?=E2=80=A6,=20migrationThreadPool)`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../textsecuregcm/storage/AccountsDynamoDb.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/storage/AccountsDynamoDb.java b/service/src/main/java/org/whispersystems/textsecuregcm/storage/AccountsDynamoDb.java index ade666b1a..000636470 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/storage/AccountsDynamoDb.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/storage/AccountsDynamoDb.java @@ -340,18 +340,23 @@ public class AccountsDynamoDb extends AbstractDynamoDbStore implements AccountSt final List> futures = accounts.stream() .map(this::migrate) - .map(f -> f.whenComplete((migrated, e) -> { + .map(f -> f.whenCompleteAsync((migrated, e) -> { if (e == null) { MIGRATED_COUNTER.increment(migrated ? 1 : 0); } else { ERROR_COUNTER.increment(); } - })) + }, migrationThreadPool)) .collect(Collectors.toList()); CompletableFuture migrationBatch = CompletableFuture.allOf(futures.toArray(new CompletableFuture[]{})); - return migrationBatch.whenComplete((result, exception) -> deleteRecentlyDeletedUuids()); + return migrationBatch.whenCompleteAsync((result, exception) -> { + if (exception != null) { + logger.warn("Exception migrating batch", exception); + } + deleteRecentlyDeletedUuids(); + }, migrationThreadPool); } public void deleteRecentlyDeletedUuids() { @@ -401,7 +406,7 @@ public class AccountsDynamoDb extends AbstractDynamoDbStore implements AccountSt logger.error("Could not store account {}", account.getUuid()); } resultFuture.completeExceptionally(exception); - }); + }, migrationThreadPool); return resultFuture; } catch (Exception e) { return CompletableFuture.failedFuture(e);