{"record":{"id":"af0fadb4e13cdc35","repo":"alibaba/spring-cloud-alibaba","slug":"support-for-specifying-both-a-day-of-week-and-a-da","errorCode":null,"errorMessage":"Support for specifying both a day-of-week AND a day-of-month parameter is not implemented.","messagePattern":"Support for specifying both a day-of-week AND a day-of-month parameter 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":308,"sourceCode":"\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);\n\t\t\t}\n\n\t\t\tfinal TreeSet<Integer> dow = getSet(DAY_OF_WEEK);\n\t\t\tfinal TreeSet<Integer> dom = getSet(DAY_OF_MONTH);\n\n\t\t\t// Copying the logic from the UnsupportedOperationException below\n\t\t\tfinal boolean dayOfMSpec = !dom.contains(NO_SPEC);\n\t\t\tfinal boolean dayOfWSpec = !dow.contains(NO_SPEC);\n\n\t\t\tif (!dayOfMSpec || dayOfWSpec) {\n\t\t\t\tif (!dayOfWSpec || dayOfMSpec) {\n\t\t\t\t\tthrow new ParseException(\n\t\t\t\t\t\t\t\"Support for specifying both a day-of-week AND a day-of-month parameter is not implemented.\", 0);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tcatch (final ParseException pe) {\n\t\t\tthrow pe;\n\t\t}\n\t\tcatch (final Exception e) {\n\t\t\tthrow new ParseException(\"Illegal cron expression format (\"\n\t\t\t\t\t+ e.toString() + \")\", 0);\n\t\t}\n\t}\n\n\tprotected int storeExpressionVals(final int pos, final String s, final int type)\n\t\t\tthrows ParseException {\n\n\t\tint incr = 0;\n\t\tint i = skipWhiteSpace(pos, s);","sourceCodeStart":290,"sourceCodeEnd":326,"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#L290-L326","documentation":"Thrown at the end of buildExpression when both day-of-month and day-of-week are explicitly specified, or both are '?'. Quartz semantics require exactly one of the two day fields to be constrained and the other to be '?' — you cannot say 'on the 1st AND on Monday' in one expression, nor '?' for both. The check at CronExpression.java:307-309 encodes this mutual exclusion.","triggerScenarios":"An expression like '0 0 0 1 * 1' (both DOM=1 and DOW=1, neither '?') or '0 0 0 ? * ?' (both '?'). dayOfMSpec/dayOfWSpec are derived from whether the set contains NO_SPEC (the '?' marker).","commonSituations":"Writing '0 0 0 1 * MON' intending 'the 1st and every Monday'; forgetting to put '?' for the unused day field; pasting a cron that uses '*' for both day fields (common in some cron dialects) instead of '?' for one.","solutions":["Use '?' for the day field you do NOT want to constrain: '0 0 0 1 * ?' (day 1 of month) or '0 0 0 ? * MON' (every Monday).","If you genuinely need both a day-of-month and a day-of-week condition, split into two triggers/jobs.","Ensure you never use '?' for both day fields simultaneously."],"exampleFix":"# before (both day fields specified -> invalid)\n0 0 0 1 * MON\n\n# after (constrain only day-of-month, '?' for day-of-week)\n0 0 0 1 * ?","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":"// quick structural check: exactly one of DOM/DOW should be '?'\nstatic boolean dayFieldsMutuallyExclusive(String[] f) {\n    boolean domQ = \"?\".equals(f[3]);\n    boolean dowQ = \"?\".equals(f[5]);\n    return domQ ^ dowQ; // exactly one is '?'\n}","tryCatchPattern":"try {\n    new CronExpression(cron);\n} catch (ParseException e) {\n    // \"Support for specifying both a day-of-week AND a day-of-month parameter is not implemented.\"\n    throw new IllegalArgumentException(\"Fix cron '\" + cron + \"': set one day field to '?'\", e);\n}","preventionTips":["Quartz rule of thumb: one day field gets a value, the other gets '?'.","Avoid '*' for both day-of-month and day-of-week; replace one with '?'."],"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"}