mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-27 16:06:39 +00:00
fix towards bug 1044: synchronize creation of control points in SwissTiming DomainFactoryImpl
This commit is contained in:
+20
-15
@@ -193,22 +193,27 @@ public class DomainFactoryImpl implements DomainFactory {
|
||||
}
|
||||
|
||||
private ControlPoint getOrCreateControlPoint(Iterable<String> devices) {
|
||||
ControlPoint result = controlPointCache.get(devices);
|
||||
if (result == null) {
|
||||
switch (Util.size(devices)) {
|
||||
case 1:
|
||||
result = getOrCreateBuoy(devices.iterator().next());
|
||||
break;
|
||||
case 2:
|
||||
Iterator<String> buoyNameIter = devices.iterator();
|
||||
String left = buoyNameIter.next();
|
||||
String right = buoyNameIter.next();
|
||||
result = baseDomainFactory.createGate(getOrCreateBuoy(left), getOrCreateBuoy(right), left+"/"+right);
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException("Don't know how to handle control points with number of devices neither 1 nor 2. Was "+Util.size(devices));
|
||||
ControlPoint result;
|
||||
synchronized (controlPointCache) {
|
||||
result = controlPointCache.get(devices);
|
||||
if (result == null) {
|
||||
switch (Util.size(devices)) {
|
||||
case 1:
|
||||
result = getOrCreateBuoy(devices.iterator().next());
|
||||
break;
|
||||
case 2:
|
||||
Iterator<String> buoyNameIter = devices.iterator();
|
||||
String left = buoyNameIter.next();
|
||||
String right = buoyNameIter.next();
|
||||
result = baseDomainFactory.createGate(getOrCreateBuoy(left), getOrCreateBuoy(right), left + "/" + right);
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException(
|
||||
"Don't know how to handle control points with number of devices neither 1 nor 2. Was "
|
||||
+ Util.size(devices));
|
||||
}
|
||||
controlPointCache.put(devices, result);
|
||||
}
|
||||
controlPointCache.put(devices, result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -376,7 +376,8 @@ public class CourseImpl extends NamedImpl implements Course {
|
||||
// new waypoint list; since several waypoints can have the same control point, the map goes from
|
||||
// control point to List<Waypoint>. The waypoints in the lists are held in the order of their
|
||||
// occurrence in courseToUpdate.getWaypoints().
|
||||
Map<com.sap.sailing.domain.base.ControlPoint, List<Waypoint>> existingWaypointsByControlPoint = new HashMap<com.sap.sailing.domain.base.ControlPoint, List<Waypoint>>();
|
||||
Map<com.sap.sailing.domain.base.ControlPoint, List<Waypoint>> existingWaypointsByControlPoint =
|
||||
new HashMap<com.sap.sailing.domain.base.ControlPoint, List<Waypoint>>();
|
||||
for (Waypoint waypoint : courseWaypoints) {
|
||||
List<Waypoint> wpl = existingWaypointsByControlPoint.get(waypoint.getControlPoint());
|
||||
if (wpl == null) {
|
||||
|
||||
Reference in New Issue
Block a user