mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-17 17:50:56 +00:00
Solving a deadlock situation of RegattaLogDeviceMappings and
MongoSensorFixStoreImpl
This commit is contained in:
1 parent
6ab4ea235d
commit
9e6457311b
2 files changed
+11
-9
No files matched your search
+10
-8
@@ -6,6 +6,7 @@ import static com.sap.sailing.domain.persistence.impl.MongoObjectFactoryImpl.sto
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
@@ -198,16 +199,17 @@ public class MongoSensorFixStoreImpl implements MongoSensorFixStore {
|
||||
storeFixes(device, Collections.singletonList(fix));
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
private <FixT extends Timed> void notifyListeners(DeviceIdentifier device, Iterable<FixT> fixes) {
|
||||
LockUtil.executeWithReadLock(listenersLock, () -> {
|
||||
for (FixT fix : fixes) {
|
||||
for (FixReceivedListener<FixT> listener : Util.<DeviceIdentifier, Set<FixReceivedListener<FixT>>> get(
|
||||
(Map) listeners, device, Collections.emptySet())) {
|
||||
listener.fixReceived(device, fix);
|
||||
}
|
||||
}
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
final Set<FixReceivedListener<FixT>> listenersToInform = LockUtil.executeWithReadLockAndResult(listenersLock, () -> {
|
||||
return new HashSet<>(Util.<DeviceIdentifier, Set<FixReceivedListener<FixT>>> get(
|
||||
(Map) listeners, device, Collections.emptySet()));
|
||||
});
|
||||
for (FixT fix : fixes) {
|
||||
for (FixReceivedListener<FixT> listener : listenersToInform) {
|
||||
listener.fixReceived(device, fix);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -245,10 +245,10 @@ public abstract class RegattaLogDeviceMappings<ItemT extends WithID> {
|
||||
}
|
||||
}
|
||||
newDeviceIds.addAll(mappingsByDevice.keySet());
|
||||
calculateDiff(oldMappings, newMappings, oldDeviceIds, newDeviceIds);
|
||||
} finally {
|
||||
LockUtil.unlockAfterWrite(mappingsLock);
|
||||
}
|
||||
calculateDiff(oldMappings, newMappings, oldDeviceIds, newDeviceIds);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user