diff --git a/java/com.sap.sailing.domain.test/src/com/sap/sailing/domain/test/TrackTest.java b/java/com.sap.sailing.domain.test/src/com/sap/sailing/domain/test/TrackTest.java index d2b4ff0c65b..b6d5c81d38d 100755 --- a/java/com.sap.sailing.domain.test/src/com/sap/sailing/domain/test/TrackTest.java +++ b/java/com.sap.sailing.domain.test/src/com/sap/sailing/domain/test/TrackTest.java @@ -56,7 +56,6 @@ import com.sap.sse.common.TimePoint; import com.sap.sse.common.Util; import com.sap.sse.common.Util.Pair; import com.sap.sse.common.impl.MillisecondsTimePoint; -import com.sap.sse.concurrent.LockUtil; public class TrackTest { private DynamicGPSFixTrack track; @@ -279,7 +278,6 @@ public class TrackTest { @Override public void gpsFixReceived(GPSFixMoving fix, Object item, boolean firstFixInTrack) { - LockUtil.lockForWrite(getLock()); try { // trigger the barrier after having acquired the cache write lock; this is what the // super.gpsFixReceived(...) method will also do (reentrantly), but this way we can @@ -289,8 +287,6 @@ public class TrackTest { gpsFixReceivedDone.await(); } catch (InterruptedException | BrokenBarrierException e) { throw new RuntimeException(e); - } finally { - LockUtil.unlockAfterWrite(getLock()); } } }; diff --git a/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/impl/MaxSpeedCache.java b/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/impl/MaxSpeedCache.java index d959481aa66..8a9ff953a49 100755 --- a/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/impl/MaxSpeedCache.java +++ b/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/impl/MaxSpeedCache.java @@ -180,8 +180,16 @@ public class MaxSpeedCache implements GPSTrack if (!to.before(from)) { result = cacheLookup(from, to); if (result == null) { - result = computeMaxSpeed(from, to); - cache(from, to, result); +// LockUtil.lockForWrite(lock); +// try { + // need to run both, the re-calculation as well as the caching, under the write lock because otherwise + // an invocation of gpsFixReceived(...) may cut in between, obtain the write lock and perform invalidations + // that would have needed to invalidate the value recalculated. + result = computeMaxSpeed(from, to); + cache(from, to, result); +// } finally { +// LockUtil.unlockAfterWrite(lock); +// } } } return result;