From ebae7b106e19e286cf1d4bc29cbdaf4532763689 Mon Sep 17 00:00:00 2001 From: Axel Uhl Date: Sat, 11 May 2019 22:19:05 +0200 Subject: [PATCH] compute assertions in MPC in all cases to provoke logging, but assert only with "assert" statement (-ea) --- .../impl/StationarySequenceBasedFilter.java | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/java/com.sap.sailing.domain/src/com/sap/sailing/domain/markpassingcalculation/impl/StationarySequenceBasedFilter.java b/java/com.sap.sailing.domain/src/com/sap/sailing/domain/markpassingcalculation/impl/StationarySequenceBasedFilter.java index 4727528aaa0..58e788e678a 100755 --- a/java/com.sap.sailing.domain/src/com/sap/sailing/domain/markpassingcalculation/impl/StationarySequenceBasedFilter.java +++ b/java/com.sap.sailing.domain/src/com/sap/sailing/domain/markpassingcalculation/impl/StationarySequenceBasedFilter.java @@ -201,7 +201,8 @@ public class StationarySequenceBasedFilter { removeCandidate(removedCandidate, candidatesEffectivelyAdded, candidatesEffectivelyRemoved); } updateFilteredCandidates(candidatesEffectivelyAdded, candidatesEffectivelyRemoved); - assert isCandidatesConsistent(); + final boolean assertion = isCandidatesConsistent(); + assert assertion; return new Pair<>(candidatesEffectivelyAdded, candidatesEffectivelyRemoved); } @@ -234,7 +235,11 @@ public class StationarySequenceBasedFilter { */ private void addCandidate(Candidate newCandidate, Set candidatesEffectivelyAdded, Set candidatesEffectivelyRemoved) { - assert !candidates.contains(newCandidate) && isCandidatesConsistent(); + if (candidates.contains(newCandidate)) { + logger.severe("Candidates "+candidates+" already contain "+newCandidate+" which is to be added."); + } + final boolean assertion = !candidates.contains(newCandidate) && isCandidatesConsistent(); + assert assertion; if (newCandidate == startProxyCandidate) { candidatesEffectivelyAdded.add(newCandidate); candidatesEffectivelyRemoved.remove(newCandidate); @@ -343,7 +348,8 @@ public class StationarySequenceBasedFilter { } else { addedToSequence = true; } - assert containsNoEmptyOrSingleCandidateStationarySequence() && isCandidatesConsistent(); + final boolean assertion = containsNoEmptyOrSingleCandidateStationarySequence() && isCandidatesConsistent(); + assert assertion; return addedToSequence; } @@ -374,7 +380,8 @@ public class StationarySequenceBasedFilter { } } } - assert containsNoEmptyOrSingleCandidateStationarySequence() && isCandidatesConsistent(); + final boolean assertion = containsNoEmptyOrSingleCandidateStationarySequence() && isCandidatesConsistent(); + assert assertion; } private StationarySequence tryToConstructStationarySequence(Candidate start, Candidate end) { @@ -417,7 +424,11 @@ public class StationarySequenceBasedFilter { candidatesEffectivelyRemoved.add(removedCandidate); candidatesEffectivelyAdded.remove(removedCandidate); } else { - assert candidates.contains(removedCandidate) && isCandidatesConsistent(); + if (!candidates.contains(removedCandidate)) { + logger.severe("Candidates "+candidates+" does not contain "+removedCandidate+" which is to be removed."); + } + final boolean assertion = candidates.contains(removedCandidate) && isCandidatesConsistent(); + assert assertion; candidates.remove(removedCandidate); final StationarySequence searchDummySequence = createStationarySequence(removedCandidate); final StationarySequence latestStationarySequenceStartingAtOrBeforeRemovedCandidate = @@ -459,6 +470,7 @@ public class StationarySequenceBasedFilter { private boolean containsNoEmptyOrSingleCandidateStationarySequence() { for (final StationarySequence ss : stationarySequences) { if (ss.size() < 2) { + logger.severe("Found stationary sequence "+ss+" with less than two candidates in it."); return false; } } @@ -504,7 +516,8 @@ public class StationarySequenceBasedFilter { */ Pair, Iterable> updateFixes(Iterable newFixes, Iterable fixesReplacingExistingOnes) { - assert isCandidatesConsistent(); + final boolean assertion = isCandidatesConsistent(); + assert assertion; final Set candidatesEffectivelyAdded = new HashSet<>(); final Set candidatesEffectivelyRemoved = new HashSet<>(); if (newFixes != null) { @@ -562,7 +575,7 @@ public class StationarySequenceBasedFilter { } } updateFilteredCandidates(candidatesEffectivelyAdded, candidatesEffectivelyRemoved); - assert containsNoEmptyOrSingleCandidateStationarySequence() && isCandidatesConsistent(); + assert containsNoEmptyOrSingleCandidateStationarySequence() && assertion; return new Pair<>(candidatesEffectivelyAdded, candidatesEffectivelyRemoved); }