alibaba/spring-cloud-alibaba · error · ParseException
'/' must be followed by an integer.
Error message
'/' must be followed by an integer.
What it means
Thrown by the Quartz-style cron parser when a field token begins with '/' but the '/' is not followed by an integer increment (it is immediately at end-of-string or followed by a space/tab). The '/' character in cron means 'every N units' and always requires a numeric step value, e.g. '*/5' or '0/10'. It surfaces as a checked java.text.ParseException from the CronExpression constructor (CronExpression.java:123 -> buildExpression -> storeExpressionVals, line 417).
Source
Thrown at spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-schedulerx/src/main/java/com/alibaba/cloud/scheduling/schedulerx/util/CronExpression.java:417
throw new ParseException(
"'?' can only be specfied for Day-of-Month -OR- Day-of-Week.",
i);
}
}
addToSet(NO_SPEC_INT, -1, 0, type);
return i;
}
if (c == '*' || c == '/') {
if (c == '*' && (i + 1) >= s.length()) {
addToSet(ALL_SPEC_INT, -1, incr, type);
return i + 1;
}
else if (c == '/'
&& ((i + 1) >= s.length() || s.charAt(i + 1) == ' ' || s
.charAt(i + 1) == '\t')) {
throw new ParseException("'/' must be followed by an integer.", i);
}
else if (c == '*') {
i++;
}
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)) {View on GitHub (pinned to 115d590110)
Solutions
- Provide a numeric increment immediately after every '/', e.g. change a bare '/' field to '*/5' or '0/15'.
- Recount the cron fields: this library requires 6 fields (seconds minutes hours day-of-month month day-of-week) plus an optional year; a missing seconds field shifts everything and can put a '/' where a field starts.
- If you meant 'every unit', use '*' alone instead of '/' — '/' alone is invalid.
- Add a pre-flight validation pass (see validationCode) before constructing CronExpression so bad config fails fast with a clear message.
Example fix
// before
new CronExpression("0 / * * * ?");
// after
new CronExpression("0 0/5 * * * ?"); // every 5 minutes Defensive patterns
Strategy: try-catch
Validate before calling
// Reject a leading '/' or a '/' followed by whitespace/end before constructing.
private static final Pattern VALID_FIELD_START =
Pattern.compile("^[?*L0-9]"); // a field must start with one of these
static boolean fieldStartsOk(String cron) {
if (cron == null) return false;
for (String f : cron.trim().split("\\s+")) {
if (f.isEmpty() || !VALID_FIELD_START.matcher(f).find()) return false;
if (f.startsWith("/") && (f.length() < 2 || !Character.isDigit(f.charAt(1)))) return false;
}
return true;
} Try / catch
try {
CronExpression cron = new CronExpression(raw);
} catch (ParseException e) {
throw new IllegalArgumentException("Invalid cron expression: " + raw, e);
} Prevention
- Always pair '/' with an explicit integer step (*/N or value/N).
- Validate cron strings at config-bind time, not at first job fire.
- Keep field count at 6 (seconds minutes hours dom month dow) to avoid shifting a '/' into a field start.
When it happens
Trigger: Constructing `new CronExpression("0 / * * * ?")` where the minute field token is a bare '/'. Also any field token equal to just '/' (e.g. day-of-month field '/'), or a token that ends right after '/' with nothing following. The guard at CronExpression.java:414-417 fires when `c == '/'` AND `i+1 >= s.length()` OR the next char is ' ' or '\t'.
Common situations: A developer writes a slash step but forgets the number (e.g. types `*/` and loses the digit in editing), or builds a cron string by concatenation and leaves a trailing '/', or copies a fragment from a 5-field cron tool into this 6/7-field parser and the fields shift so a '/' lands at a field start.
Related errors
- Unexpected end of string.
- Increment > 60 : {}
- Increment > 24 : {}
- Increment > 31 : {}
- Increment > 7 : {}
AI-assisted analysis of alibaba/spring-cloud-alibaba@115d590110 (2026-08-14).
Data as JSON: /api/errors/07da3f02f9fcd215.
Report an issue: GitHub.