From 0d566b88b0cde778209a1cc9eb396bc86ea07818 Mon Sep 17 00:00:00 2001 From: Andrea Cavalli Date: Wed, 30 Sep 2020 22:43:53 +0200 Subject: [PATCH] Update pom.xml, CompletableFutureUtils.java, and FloatPriorityQueue.java --- pom.xml | 2 +- .../concurrency/future/CompletableFutureUtils.java | 4 ++-- .../java/org/warp/commonutils/type/FloatPriorityQueue.java | 4 +++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 27e6d4d..620e16e 100644 --- a/pom.xml +++ b/pom.xml @@ -68,7 +68,7 @@ org.jetbrains annotations - 17.0.0 + 19.0.0 com.google.guava diff --git a/src/main/java/org/warp/commonutils/concurrency/future/CompletableFutureUtils.java b/src/main/java/org/warp/commonutils/concurrency/future/CompletableFutureUtils.java index 9339e76..fc28d5f 100644 --- a/src/main/java/org/warp/commonutils/concurrency/future/CompletableFutureUtils.java +++ b/src/main/java/org/warp/commonutils/concurrency/future/CompletableFutureUtils.java @@ -184,8 +184,8 @@ public class CompletableFutureUtils { public static CompletableFuture> aggregatePq(Collection>> futureFloatPriorityQueues) { final CompletableFuture> identityAggregatedResult = CompletableFuture.completedFuture(new FloatPriorityQueue<>()); - return futureFloatPriorityQueues.parallelStream().reduce(identityAggregatedResult, (currentAggregatedResult, futureFloatPriorityQueue) -> { - return currentAggregatedResult.thenApplyAsync((aggregatedFloatPriorityQueue) -> { + return futureFloatPriorityQueues.stream().reduce(identityAggregatedResult, (currentAggregatedResult, futureFloatPriorityQueue) -> { + return currentAggregatedResult.thenApply((aggregatedFloatPriorityQueue) -> { var futureFloatPriorityQueueValues = futureFloatPriorityQueue.join(); if (futureFloatPriorityQueueValues == aggregatedFloatPriorityQueue) { return aggregatedFloatPriorityQueue; diff --git a/src/main/java/org/warp/commonutils/type/FloatPriorityQueue.java b/src/main/java/org/warp/commonutils/type/FloatPriorityQueue.java index 8fcdd38..fa8fab0 100644 --- a/src/main/java/org/warp/commonutils/type/FloatPriorityQueue.java +++ b/src/main/java/org/warp/commonutils/type/FloatPriorityQueue.java @@ -224,7 +224,9 @@ public class FloatPriorityQueue implements Queue { } public boolean offer(ScoredValue value) { - assert contentValues.size() == internalQueue.size(); + int contentValuesSize = contentValues.size(); + int internalQueueSize = internalQueue.size(); + assert contentValuesSize == internalQueueSize; boolean added = true; float oldValue;