From 7a8270c69f9a5df0d754bb508c1ac918680639b4 Mon Sep 17 00:00:00 2001 From: LSmyrnaios Date: Thu, 4 Jul 2024 01:35:31 +0300 Subject: [PATCH] - Perform manual synchronization on "BulkImportReport.eventsMultimap", in order to avoid the "ConcurrentModificationException" when requesting a BulkImport-report. - Prepare app-version for next release. --- build.gradle | 2 +- .../openaire/urls_controller/models/BulkImportReport.java | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index 5d53800..540d704 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ plugins { java { group = 'eu.openaire.urls_controller' - version = '2.8.0' + version = '2.8.1-SNAPSHOT' sourceCompatibility = JavaVersion.VERSION_1_8 } diff --git a/src/main/java/eu/openaire/urls_controller/models/BulkImportReport.java b/src/main/java/eu/openaire/urls_controller/models/BulkImportReport.java index ccc80d8..b9b8d0e 100644 --- a/src/main/java/eu/openaire/urls_controller/models/BulkImportReport.java +++ b/src/main/java/eu/openaire/urls_controller/models/BulkImportReport.java @@ -34,12 +34,12 @@ public class BulkImportReport { private String reportID; // This will not be serialized, since Gson cannot serialize Multimaps. Instead, it will be converted to the "simpler" map below. - transient private SetMultimap eventsMultimap = Multimaps.synchronizedSetMultimap(LinkedHashMultimap.create()); + transient private SetMultimap eventsMultimap = LinkedHashMultimap.create(); // We need a "LinkedHashMultimap", se that the order of the keys (timestamps) stay ascending, so the final report makes sense in chronological order. // We need for one key (timestamp) to have multiple values (events), in order to not lose events happening at the same time. @JsonProperty - private Map> eventsMap; + private Map> eventsMap = null; transient private final Lock reportLock = new ReentrantLock(true); @@ -52,7 +52,9 @@ public class BulkImportReport { public void addEvent(String event) { + reportLock.lock(); eventsMultimap.put(GenericUtils.getReadableCurrentTimeAndZone(), event); // This is synchronized. + reportLock.unlock(); } /**