Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Don't allow interval to be set with 0 or negative values. (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
tryantwit authored and jinsoor-amzn committed Aug 13, 2019
1 parent ec9292d commit d3e29a6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,10 @@ data class IntervalSchedule(
if (!SUPPORTED_UNIT.contains(unit)) {
throw IllegalArgumentException("Timezone $unit is not supported expected $SUPPORTED_UNIT")
}

if (interval <= 0) {
throw IllegalArgumentException("Interval is not allowed to be 0 or negative")
}
}

@Transient
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,5 +336,9 @@ class ScheduleTest : XContentTestBase {
assertFailsWith(IllegalArgumentException::class, "Expected IllegalArgumentException") {
IntervalSchedule(1, ChronoUnit.MONTHS)
}

assertFailsWith(IllegalArgumentException::class, "Expected IllegalArgumentException") {
IntervalSchedule(-1, ChronoUnit.MINUTES)
}
}
}

0 comments on commit d3e29a6

Please sign in to comment.