{"record":{"id":"34335978f4d37785","repo":"alibaba/spring-cloud-alibaba","slug":"support-for-specifying-multiple-nth-days-is-not","errorCode":null,"errorMessage":"Support for specifying multiple \"nth\" days is not implemented.","messagePattern":"Support for specifying multiple \"nth\" days is not implemented\\.","errorType":"exception","errorClass":"ParseException","httpStatus":null,"severity":"error","filePath":"spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-schedulerx/src/main/java/com/alibaba/cloud/scheduling/schedulerx/util/CronExpression.java","lineNumber":278,"sourceCode":"\n\t\t\tint exprOn = SECOND;\n\n\t\t\tfinal StringTokenizer exprsTok = new StringTokenizer(expression, \" \\t\",\n\t\t\t\t\tfalse);\n\n\t\t\twhile (exprsTok.hasMoreTokens() && exprOn <= YEAR) {\n\t\t\t\tfinal String expr = exprsTok.nextToken().trim();\n\n\t\t\t\t// throw an exception if L is used with other days of the month\n\t\t\t\tif (exprOn == DAY_OF_MONTH && expr.indexOf('L') != -1 && expr.length() > 1 && expr.contains(\",\")) {\n\t\t\t\t\tthrow new ParseException(\"Support for specifying 'L' and 'LW' with other days of the month is not implemented\", -1);\n\t\t\t\t}\n\t\t\t\t// throw an exception if L is used with other days of the week\n\t\t\t\tif (exprOn == DAY_OF_WEEK && expr.indexOf('L') != -1 && expr.length() > 1 && expr.contains(\",\")) {\n\t\t\t\t\tthrow new ParseException(\"Support for specifying 'L' with other days of the week is not implemented\", -1);\n\t\t\t\t}\n\t\t\t\tif (exprOn == DAY_OF_WEEK && expr.indexOf('#') != -1 && expr.indexOf('#', expr.indexOf('#') + 1) != -1) {\n\t\t\t\t\tthrow new ParseException(\"Support for specifying multiple \\\"nth\\\" days is not implemented.\", -1);\n\t\t\t\t}\n\n\t\t\t\tfinal StringTokenizer vTok = new StringTokenizer(expr, \",\");\n\t\t\t\twhile (vTok.hasMoreTokens()) {\n\t\t\t\t\tfinal String v = vTok.nextToken();\n\t\t\t\t\tstoreExpressionVals(0, v, exprOn);\n\t\t\t\t}\n\n\t\t\t\texprOn++;\n\t\t\t}\n\n\t\t\tif (exprOn <= DAY_OF_WEEK) {\n\t\t\t\tthrow new ParseException(\"Unexpected end of expression.\",\n\t\t\t\t\t\texpression.length());\n\t\t\t}\n\n\t\t\tif (exprOn <= YEAR) {\n\t\t\t\tstoreExpressionVals(0, \"*\", YEAR);","sourceCodeStart":260,"sourceCodeEnd":296,"githubUrl":"https://github.com/alibaba/spring-cloud-alibaba/blob/115d5901102009492e05d5ec18c3f79cad4077d0/spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-schedulerx/src/main/java/com/alibaba/cloud/scheduling/schedulerx/util/CronExpression.java#L260-L296","documentation":"Thrown during parsing of the DAY_OF_WEEK field when a single token contains more than one '#' character. The '#' modifier means 'the Nth weekday of the month' (e.g. '5#2' = second Friday); Quartz forbids multiple '#' specifiers in one field, so the parser throws ParseException.","triggerScenarios":"A day-of-week token like '5#2#3' (two '#' in one field). The check at CronExpression.java:276-278 fires when indexOf('#')!=-1 and a second '#' exists after the first.","commonSituations":"Attempting 'the 2nd and 3rd Friday' as '5#2#3' instead of two triggers; a typo inserting an extra '#'; malformed generated cron from a UI.","solutions":["Use one '#' per trigger and create multiple triggers for multiple nth-weekday rules.","Correct the token to a single '<dow>#<n>' (n between 1 and 5).","Validate the cron expression at config load."],"exampleFix":"# before (invalid: two '#' in one field)\n0 0 0 ? * 5#2#3\n\n# after (two triggers, one nth-day each)\n0 0 0 ? * 5#2\n0 0 0 ? * 5#3","handlingStrategy":"try-catch","validationCode":"static String validateCron(String cron) throws ParseException {\n    new com.alibaba.cloud.scheduling.schedulerx.util.CronExpression(cron);\n    return cron;\n}","typeGuard":"// day-of-week token must contain at most one '#'\nstatic boolean atMostOneHash(String dowToken) {\n    return dowToken.indexOf('#') == dowToken.lastIndexOf('#');\n}","tryCatchPattern":"try {\n    new CronExpression(cron);\n} catch (ParseException e) {\n    // \"Support for specifying multiple \\\"nth\\\" days is not implemented.\"\n    throw new IllegalArgumentException(\"Invalid cron '\" + cron + \"'\", e);\n}","preventionTips":["Limit each day-of-week token to a single '#' modifier; use multiple triggers for multiple nth-days.","Sanitize UI-generated cron before storing it."],"tags":["java","schedulerx","cron","parsing","validation"],"backgroundTag":null,"analyzedSha":"115d5901102009492e05d5ec18c3f79cad4077d0","analyzedAt":"2026-08-14T04:47:13.900Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}