Skip to content

Commit

Permalink
Ugly shameful fix for the endTime/startTime infamous bug
Browse files Browse the repository at this point in the history
The blame is on me...
  • Loading branch information
adejanovski committed Dec 18, 2017
1 parent 22124c1 commit 78b0fbd
Showing 1 changed file with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import java.math.BigInteger;
import java.util.UUID;

import javax.annotation.Nullable;

import com.google.common.base.Preconditions;
Expand Down Expand Up @@ -179,12 +180,19 @@ public Builder endTime(DateTime endTime) {
public RepairSegment build(@Nullable UUID segmentId) {
// a null segmentId is a special case where the storage uses a sequence for it
Preconditions.checkNotNull(runId);
Preconditions.checkState(null != startTime || null == endTime, "if endTime is set, so must startTime be set");
Preconditions.checkState(null == endTime || State.DONE == state, "endTime can only be set if segment is DONE");

Preconditions.checkState(
null != startTime || State.NOT_STARTED == state,
"startTime must be set if segment is RUNNING or DONE");
//Preconditions.checkState(null != startTime || null == endTime, "if endTime is set, so must startTime be set");
//Preconditions.checkState(null == endTime || State.DONE == state, "endTime can only be set if segment is DONE");
/* Preconditions.checkState(
null != startTime || State.NOT_STARTED == state,
"startTime must be set if segment is RUNNING or DONE"); */

if (null != endTime && State.DONE != state) {
endTime = null;
}

if (startTime == null && endTime != null) {
startTime = endTime.minusSeconds(1);
}

return new RepairSegment(this, segmentId);
}
Expand Down

0 comments on commit 78b0fbd

Please sign in to comment.