alibaba/spring-cloud-alibaba · error · ParseException
Support for specifying 'L' with other days of the week is no
Error message
Support for specifying 'L' with other days of the week is not implemented
What it means
Thrown during CronExpression.buildExpression while parsing the DAY_OF_WEEK field: if the token contains 'L' (e.g. '6L' = last Friday), is longer than one char, and also contains a comma, the parser throws ParseException. Quartz does not support mixing the 'last weekday of month' modifier with a list of other weekdays.
Source
Thrown at spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-schedulerx/src/main/java/com/alibaba/cloud/scheduling/schedulerx/util/CronExpression.java:275
months = new TreeSet<>();
daysOfWeek = new TreeSet<>();
years = new TreeSet<>();
int exprOn = SECOND;
final StringTokenizer exprsTok = new StringTokenizer(expression, " \t",
false);
while (exprsTok.hasMoreTokens() && exprOn <= YEAR) {
final String expr = exprsTok.nextToken().trim();
// throw an exception if L is used with other days of the month
if (exprOn == DAY_OF_MONTH && expr.indexOf('L') != -1 && expr.length() > 1 && expr.contains(",")) {
throw new ParseException("Support for specifying 'L' and 'LW' with other days of the month is not implemented", -1);
}
// throw an exception if L is used with other days of the week
if (exprOn == DAY_OF_WEEK && expr.indexOf('L') != -1 && expr.length() > 1 && expr.contains(",")) {
throw new ParseException("Support for specifying 'L' with other days of the week is not implemented", -1);
}
if (exprOn == DAY_OF_WEEK && expr.indexOf('#') != -1 && expr.indexOf('#', expr.indexOf('#') + 1) != -1) {
throw new ParseException("Support for specifying multiple \"nth\" days is not implemented.", -1);
}
final StringTokenizer vTok = new StringTokenizer(expr, ",");
while (vTok.hasMoreTokens()) {
final String v = vTok.nextToken();
storeExpressionVals(0, v, exprOn);
}
exprOn++;
}
if (exprOn <= DAY_OF_WEEK) {
throw new ParseException("Unexpected end of expression.",
expression.length());
}View on GitHub (pinned to 115d590110)
Solutions
- Split into two triggers: one for the recurring weekday ('0 0 0 ? * MON') and one for the last-weekday rule ('0 0 0 ? * 6L').
- If only the last weekday is needed, use the L form alone without a comma list.
- Pre-validate all cron expressions at startup.
Example fix
# before (invalid: L mixed in day-of-week list) 0 0 0 ? * MON,6L # after (two triggers) 0 0 0 ? * MON 0 0 0 ? * 6L
Defensive patterns
Strategy: try-catch
Validate before calling
static String validateCron(String cron) throws ParseException {
new com.alibaba.cloud.scheduling.schedulerx.util.CronExpression(cron);
return cron;
} Type guard
// reject day-of-week lists containing L before parsing
static boolean isValidDow(String dow) {
boolean hasL = dow.indexOf('L') != -1;
return !(hasL && dow.length() > 1 && dow.contains(","));
} Try / catch
try {
new CronExpression(cron);
} catch (ParseException e) {
log.error("Bad day-of-week cron '{}': {}", cron, e.getMessage());
throw e;
} Prevention
- Do not mix 'L' (last weekday) with comma-separated weekdays; use multiple triggers.
- Trial-parse crons during config validation so mistakes surface before runtime.
When it happens
Trigger: A cron whose day-of-week field is a list including an L form, e.g. '0 0 0 ? * MON,6L'. The guard at CronExpression.java:273-275 matches DAY_OF_WEEK && indexOf('L')!=-1 && length()>1 && contains(',').
Common situations: Wanting 'every Monday and the last Friday' and writing 'MON,6L'; converting a natural-language schedule that bundles a weekly day with a 'last weekday' rule.
Related errors
- Support for specifying 'L' and 'LW' with other days of the m
- Support for specifying multiple "nth" days is not implemente
- Unexpected end of expression.
- Support for specifying both a day-of-week AND a day-of-month
- Illegal cron expression format ({})
AI-assisted analysis of alibaba/spring-cloud-alibaba@115d590110 (2026-08-14).
Data as JSON: /api/errors/90ee69f3c55ffe89.
Report an issue: GitHub.