alibaba/spring-cloud-alibaba · error · ParseException
Increment > 24 : {}
Error message
Increment > 24 : {} What it means
Thrown when a step value after '/' exceeds 23 in the HOUR field (guard at CronExpression.java:438-439). Hour steps must be within the 0-23 hour range; the message reports '> 24' though the code checks `incr > 23`.
Source
Thrown at spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-schedulerx/src/main/java/com/alibaba/cloud/scheduling/schedulerx/util/CronExpression.java:439
}
c = s.charAt(i);
if (c == '/') { // is an increment specified?
i++;
if (i >= s.length()) {
throw new ParseException("Unexpected end of string.", i);
}
incr = getNumericValue(s, i);
i++;
if (incr > 10) {
i++;
}
if (incr > 59 && (type == SECOND || type == MINUTE)) {
throw new ParseException("Increment > 60 : " + incr, i);
}
else if (incr > 23 && (type == HOUR)) {
throw new ParseException("Increment > 24 : " + incr, i);
}
else if (incr > 31 && (type == DAY_OF_MONTH)) {
throw new ParseException("Increment > 31 : " + incr, i);
}
else if (incr > 7 && (type == DAY_OF_WEEK)) {
throw new ParseException("Increment > 7 : " + incr, i);
}
else if (incr > 12 && (type == MONTH)) {
throw new ParseException("Increment > 12 : " + incr, i);
}
}
else {
incr = 1;
}
addToSet(ALL_SPEC_INT, -1, incr, type);
return i;
}View on GitHub (pinned to 115d590110)
Solutions
- Use a step <= 23 for hours, e.g. '*/24' -> '*/12'.
- For 'every 24 hours / every day at a time', use a fixed hour like '0 0 12 * * ?' instead of a step.
- Recount the six fields to ensure the step is actually in the hours position.
Example fix
// before
new CronExpression("0 0 */24 * * ?");
// after
new CronExpression("0 0 */12 * * ?"); // every 12 hours Defensive patterns
Strategy: validation
Validate before calling
static boolean stepWithin(String field, int max) {
int slash = field.indexOf('/');
if (slash < 0) return true;
try { return Integer.parseInt(field.substring(slash + 1)) <= max; }
catch (NumberFormatException e) { return false; }
} Try / catch
try {
CronExpression cron = new CronExpression(raw);
} catch (ParseException e) {
throw new IllegalArgumentException("Invalid cron expression: " + raw, e);
} Prevention
- Hour steps are capped at 23; for 'every 24h' use a fixed daily time.
- Validate hour-step inputs at the configuration boundary.
- Recount fields to keep the step in the hours position.
When it happens
Trigger: `new CronExpression("0 0 */24 * * ?")` (hour step 24) or any `*/NN`/`N/NN` in the hours field with NN > 23.
Common situations: Wanting 'every 24 hours' which cron cannot express as a single hour step, or an off-by-one from a 1-based UI. Also a field-shift bug where a day-of-month value lands in the hours field.
Related errors
- Increment > 60 : {}
- Increment > 31 : {}
- Increment > 7 : {}
- Increment > 12 : {}
- Offset from last day must be <= 30
AI-assisted analysis of alibaba/spring-cloud-alibaba@115d590110 (2026-08-14).
Data as JSON: /api/errors/8bd518d073e40fdb.
Report an issue: GitHub.