From 871bb044514e3f0f006f9408070c5db1dc1afa31 Mon Sep 17 00:00:00 2001 From: Keir Nellyer Date: Fri, 24 Jun 2016 17:45:56 +0100 Subject: [PATCH] Fix /reporthandle command --- .../report/command/ReportHandleCommand.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportHandleCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportHandleCommand.java index 0429a2c1a..1faee0da3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportHandleCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportHandleCommand.java @@ -1,8 +1,9 @@ package mineplex.core.report.command; +import java.util.Collections; +import java.util.HashMap; import java.util.Map; import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ConcurrentHashMap; import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; @@ -32,17 +33,16 @@ public class ReportHandleCommand extends CommandBase { ReportManager reportManager = Plugin.getReportManager(); ReportRepository reportRepository = reportManager.getReportRepository(); - Map reportPriorities = new ConcurrentHashMap<>(); + Map reportPriorities = Collections.synchronizedMap(new HashMap<>()); // the below fetches the ids of all unhandled reports and gets a Report object for each of these ids // the priority of the report is then calculated and the results placed in a map - CompletableFuture.allOf( - reportRepository.getUnhandledReports().thenCompose(reportRepository::getReports).thenAccept(reports -> - reports.stream().map(report -> - reportManager.calculatePriority(report).thenAccept(priority -> - reportPriorities.put(report, priority) - ) - ).toArray(CompletableFuture[]::new)) + reportRepository.getUnhandledReports().thenCompose(reportRepository::getReports).thenAccept(reports -> + CompletableFuture.allOf(reports.stream().map(report -> + reportManager.calculatePriority(report).thenAccept(priority -> + reportPriorities.put(report, priority) + ) + ).toArray(CompletableFuture[]::new)).join() ).thenApply(aVoid -> { Map.Entry mostImportant = null;