forked from lsmyrnaios/UrlsController
- Perform manual synchronization on "BulkImportReport.eventsMultimap", in order to avoid the "ConcurrentModificationException" when requesting a BulkImport-report.
- Prepare app-version for next release.
This commit is contained in:
parent
9e9f417f1f
commit
7a8270c69f
|
@ -6,7 +6,7 @@ plugins {
|
||||||
|
|
||||||
java {
|
java {
|
||||||
group = 'eu.openaire.urls_controller'
|
group = 'eu.openaire.urls_controller'
|
||||||
version = '2.8.0'
|
version = '2.8.1-SNAPSHOT'
|
||||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,12 +34,12 @@ public class BulkImportReport {
|
||||||
private String reportID;
|
private String reportID;
|
||||||
|
|
||||||
// This will not be serialized, since Gson cannot serialize Multimaps. Instead, it will be converted to the "simpler" map below.
|
// This will not be serialized, since Gson cannot serialize Multimaps. Instead, it will be converted to the "simpler" map below.
|
||||||
transient private SetMultimap<String, String> eventsMultimap = Multimaps.synchronizedSetMultimap(LinkedHashMultimap.create());
|
transient private SetMultimap<String, String> 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 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.
|
// We need for one key (timestamp) to have multiple values (events), in order to not lose events happening at the same time.
|
||||||
|
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
private Map<String, Collection<String>> eventsMap;
|
private Map<String, Collection<String>> eventsMap = null;
|
||||||
|
|
||||||
transient private final Lock reportLock = new ReentrantLock(true);
|
transient private final Lock reportLock = new ReentrantLock(true);
|
||||||
|
|
||||||
|
@ -52,7 +52,9 @@ public class BulkImportReport {
|
||||||
|
|
||||||
|
|
||||||
public void addEvent(String event) {
|
public void addEvent(String event) {
|
||||||
|
reportLock.lock();
|
||||||
eventsMultimap.put(GenericUtils.getReadableCurrentTimeAndZone(), event); // This is synchronized.
|
eventsMultimap.put(GenericUtils.getReadableCurrentTimeAndZone(), event); // This is synchronized.
|
||||||
|
reportLock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue