diff --git a/java/com.sap.sailing.domain.shared.android/src/com/sap/sailing/domain/tracking/Track.java b/java/com.sap.sailing.domain.shared.android/src/com/sap/sailing/domain/tracking/Track.java index 21f32616e4c..75010f03c8d 100755 --- a/java/com.sap.sailing.domain.shared.android/src/com/sap/sailing/domain/tracking/Track.java +++ b/java/com.sap.sailing.domain.shared.android/src/com/sap/sailing/domain/tracking/Track.java @@ -201,6 +201,17 @@ public interface Track extends Serializable { */ Iterator getRawFixesIterator(TimePoint startingAt, boolean inclusive); + /** + * Returns an iterator starting at the first raw fix after startingAt (or "at or after" in case + * startingAtInclusive is true) and ending at the endingAt time point or just before + * in case endingAtIncluive is false. The fixes returned by the iterator are the raw fixes (see also + * {@link #getRawFixes()}, without any smoothening or dampening applied. + * + * Callers must have called {@link #lockForRead()} before calling this method. This will be checked, and an exception + * will be thrown in case the caller has failed to do so. + */ + Iterator getRawFixesIterator(TimePoint startingAt, boolean startingAtInclusive, TimePoint endingAt, boolean endingAtInclusive); + /** * Returns a descending iterator starting at the first fix before startingAt (or "at or before" in case * inclusive is true). The fixes returned by the iterator are the smoothened fixes (see diff --git a/java/com.sap.sailing.domain.shared.android/src/com/sap/sailing/domain/tracking/impl/TrackImpl.java b/java/com.sap.sailing.domain.shared.android/src/com/sap/sailing/domain/tracking/impl/TrackImpl.java index 4cc8b21766c..d0d9cf9b890 100644 --- a/java/com.sap.sailing.domain.shared.android/src/com/sap/sailing/domain/tracking/impl/TrackImpl.java +++ b/java/com.sap.sailing.domain.shared.android/src/com/sap/sailing/domain/tracking/impl/TrackImpl.java @@ -335,25 +335,14 @@ public class TrackImpl implements Track { @Override public Iterator getFixesIterator(TimePoint startingAt, boolean inclusive) { assertReadLock(); - Iterator result = (Iterator) getInternalFixes().tailSet( - getDummyFix(startingAt), inclusive).iterator(); - return result; + return getTimeConstrainedFixesIterator(getInternalFixes(), startingAt, inclusive, /* endingAt */ null, /* endingAtInclusive */ false); } @Override public Iterator getFixesIterator(TimePoint startingAt, boolean startingAtInclusive, TimePoint endingAt, boolean endingAtInclusive) { assertReadLock(); - NavigableSet set = getInternalFixes(); - if (startingAt != null && endingAt != null) { - set = set.subSet(getDummyFix(startingAt), startingAtInclusive, getDummyFix(endingAt), endingAtInclusive); - } else if (endingAt != null) { - set = set.headSet(getDummyFix(endingAt), endingAtInclusive); - } else if (startingAt != null) { - set = set.tailSet(getDummyFix(startingAt), startingAtInclusive); - } - Iterator result = set.iterator(); - return result; + return getTimeConstrainedFixesIterator(getInternalFixes(), startingAt, startingAtInclusive, endingAt, endingAtInclusive); } @Override @@ -380,10 +369,29 @@ public class TrackImpl implements Track { @Override public Iterator getRawFixesIterator(TimePoint startingAt, boolean inclusive) { assertReadLock(); - Iterator result = (Iterator) getInternalRawFixes().tailSet( - getDummyFix(startingAt), inclusive).iterator(); + return getTimeConstrainedFixesIterator(getInternalRawFixes(), startingAt, inclusive, /* endingAt */ null, /* endingAtInclusive */ false); + } + + private Iterator getTimeConstrainedFixesIterator(NavigableSet set, TimePoint startingAt, boolean startingAtInclusive, + TimePoint endingAt, boolean endingAtInclusive) { + assertReadLock(); + if (startingAt != null && endingAt != null) { + set = set.subSet(getDummyFix(startingAt), startingAtInclusive, getDummyFix(endingAt), endingAtInclusive); + } else if (endingAt != null) { + set = set.headSet(getDummyFix(endingAt), endingAtInclusive); + } else if (startingAt != null) { + set = set.tailSet(getDummyFix(startingAt), startingAtInclusive); + } + Iterator result = set.iterator(); return result; } + + @Override + public Iterator getRawFixesIterator(TimePoint startingAt, boolean startingAtInclusive, + TimePoint endingAt, boolean endingAtInclusive) { + assertReadLock(); + return getTimeConstrainedFixesIterator(getInternalRawFixes(), startingAt, startingAtInclusive, endingAt, endingAtInclusive); + } @Override public Iterator getRawFixesDescendingIterator(TimePoint startingAt, boolean inclusive) { diff --git a/java/com.sap.sailing.domain/src/com/sap/sailing/domain/markpassingcalculation/MarkPassingCalculator.java b/java/com.sap.sailing.domain/src/com/sap/sailing/domain/markpassingcalculation/MarkPassingCalculator.java index 9207ebfdd46..16c5d08278e 100755 --- a/java/com.sap.sailing.domain/src/com/sap/sailing/domain/markpassingcalculation/MarkPassingCalculator.java +++ b/java/com.sap.sailing.domain/src/com/sap/sailing/domain/markpassingcalculation/MarkPassingCalculator.java @@ -1,5 +1,6 @@ package com.sap.sailing.domain.markpassingcalculation; +import java.lang.Thread.State; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -507,8 +508,13 @@ public class MarkPassingCalculator { queue.add(update); // regardless of whether the queue is empty or not, launch the thread if it doesn't run yet and we are not suspended; // the queue may have filled up while we were suspended - if (!suspended && listenerThread == null) { - listenerThread = createAndStartListenerThread(); + if (!suspended) { + if (listenerThread == null) { + listenerThread = createAndStartListenerThread(); + } else if (listenerThread.getState() == State.TERMINATED) { + logger.severe("Listener thread of MarkPassingCalculator (MPC) for race "+race.getRace().getName()+ + " terminated but not null. Why are we still receiving updates? We must have been stopped before!"); + } } } } diff --git a/java/com.sap.sailing.domain/src/com/sap/sailing/domain/markpassingcalculation/impl/StationarySequence.java b/java/com.sap.sailing.domain/src/com/sap/sailing/domain/markpassingcalculation/impl/StationarySequence.java index 4f8808edcbc..50e87a6c0b0 100755 --- a/java/com.sap.sailing.domain/src/com/sap/sailing/domain/markpassingcalculation/impl/StationarySequence.java +++ b/java/com.sap.sailing.domain/src/com/sap/sailing/domain/markpassingcalculation/impl/StationarySequence.java @@ -108,7 +108,7 @@ public class StationarySequence { if (bounds != null) { track.lockForRead(); try { - final Iterator iter = track.getFixesIterator(start.getTimePoint(), /* inclusive */ true, + final Iterator iter = track.getRawFixesIterator(start.getTimePoint(), /* inclusive */ true, end.getTimePoint(), /* inclusive */ true); while (iter.hasNext()) { final GPSFixMoving fix = iter.next(); diff --git a/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/impl/TrackedRaceImpl.java b/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/impl/TrackedRaceImpl.java index d8297647876..239fa7dfc9e 100755 --- a/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/impl/TrackedRaceImpl.java +++ b/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/impl/TrackedRaceImpl.java @@ -557,9 +557,9 @@ public abstract class TrackedRaceImpl extends TrackedRaceWithWindEssentials impl @Override public void raceRemoved(TrackedRace trackedRace) { if (trackedRace == TrackedRaceImpl.this) { - // stop mark passing calculator when tracked race is removed: - markPassingCalculator.stop(); - } + // stop mark passing calculator when tracked race is removed: + markPassingCalculator.stop(); + } } }, /* Not relevant For replication */ Optional.empty(), /* synchronous */ false); } else { diff --git a/java/com.sap.sailing.server/SailingServer (No Proxy).launch b/java/com.sap.sailing.server/SailingServer (No Proxy).launch index 183250fecdf..38159b06b76 100755 --- a/java/com.sap.sailing.server/SailingServer (No Proxy).launch +++ b/java/com.sap.sailing.server/SailingServer (No Proxy).launch @@ -1,40 +1,40 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +