Skip to content

Commit fca4216

Browse files
committed
fix(core): Return no config for stepped single value ranges
Spring and Quartz run 10-10/2 only at 10, cronsim steps to the field max.
1 parent bd47026 commit fca4216

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

‎sentry/src/main/java/io/sentry/util/MonitorConfigUtils.java‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,10 @@ private MonitorConfigUtils() {}
370370
return null;
371371
}
372372
if (items.size() == 1) {
373+
// cronsim steps a single value range like 10-10/2 to the field max
374+
if (base.indexOf('-') >= 0) {
375+
return null;
376+
}
373377
return range(items.iterator().next(), FIELD_MAX[index], step);
374378
}
375379
final @NotNull List<Integer> sorted = new ArrayList<>(items);

‎sentry/src/test/java/io/sentry/util/MonitorConfigUtilsTest.kt‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,15 @@ class MonitorConfigUtilsTest {
151151
}
152152
}
153153

154+
@Test
155+
fun `stepped single value range returns null`() {
156+
// Spring and Quartz run only at the value, cronsim steps to the field max
157+
for (cron in
158+
listOf("0 10-10/2 * * * *", "0 0 0-0/3 * * *", "0 0 0 ? * 4-4/3", "0 0 0 * 6-6/1 *")) {
159+
assertThat(MonitorConfigUtils.fromSchedule(cron, null, null, null)).isNull()
160+
}
161+
}
162+
154163
@Test
155164
fun `disabled cron returns null`() {
156165
assertThat(MonitorConfigUtils.fromSchedule("-", null, null, null)).isNull()

0 commit comments

Comments
 (0)