{"record":{"id":"2795a4fa79d4be5d","repo":"jeecgboot/JeecgBoot","slug":"unexpected-end-of-expression","errorCode":null,"errorMessage":"Unexpected end of expression.","messagePattern":"Unexpected end of expression\\.","errorType":"exception","errorClass":"ParseException","httpStatus":null,"severity":"error","filePath":"jeecg-boot/jeecg-server-cloud/jeecg-visual/jeecg-cloud-xxljob/src/main/java/com/xxl/job/admin/business/scheduler/cron/CronExpression.java","lineNumber":507,"sourceCode":"                // throw an exception if L is used with other days of the week\n                if(exprOn == DAY_OF_WEEK && expr.indexOf('L') != -1 && expr.length() > 1  && expr.contains(\",\")) {\n                    throw new ParseException(\"Support for specifying 'L' with other days of the week is not implemented\", -1);\n                }\n                if(exprOn == DAY_OF_WEEK && expr.indexOf('#') != -1 && expr.indexOf('#', expr.indexOf('#') +1) != -1) {\n                    throw new ParseException(\"Support for specifying multiple \\\"nth\\\" days is not implemented.\", -1);\n                }\n\n                StringTokenizer vTok = new StringTokenizer(expr, \",\");\n                while (vTok.hasMoreTokens()) {\n                    String v = vTok.nextToken();\n                    storeExpressionVals(0, v, exprOn);\n                }\n\n                exprOn++;\n            }\n\n            if (exprOn <= DAY_OF_WEEK) {\n                throw new ParseException(\"Unexpected end of expression.\",\n                        expression.length());\n            }\n\n            if (exprOn <= YEAR) {\n                storeExpressionVals(0, \"*\", YEAR);\n            }\n\n            TreeSet<Integer> dow = getSet(DAY_OF_WEEK);\n            TreeSet<Integer> dom = getSet(DAY_OF_MONTH);\n\n            // Copying the logic from the UnsupportedOperationException below\n            boolean dayOfMSpec = !dom.contains(NO_SPEC);\n            boolean dayOfWSpec = !dow.contains(NO_SPEC);\n\n            if (!dayOfMSpec || dayOfWSpec) {\n                if (!dayOfWSpec || dayOfMSpec) {\n                    throw new ParseException(\n                            \"Support for specifying both a day-of-week AND a day-of-month parameter is not implemented.\", 0);","sourceCodeStart":489,"sourceCodeEnd":525,"githubUrl":"https://github.com/jeecgboot/JeecgBoot/blob/96fb33f5ec68516da0b0147da06b2eb0419e063a/jeecg-boot/jeecg-server-cloud/jeecg-visual/jeecg-cloud-xxljob/src/main/java/com/xxl/job/admin/business/scheduler/cron/CronExpression.java#L489-L525","documentation":"Thrown by CronExpression's parser when the expression has fewer than 6 fields after tokenization completes. The parser tracks which field it has processed via exprOn (starting at SECOND=1 through YEAR=7). If after consuming all tokens, exprOn is still at or below DAY_OF_WEEK (field 5), the expression is too short. A valid Quartz cron requires at least 6 fields (seconds through day-of-week). The error position is set to the expression length.","triggerScenarios":"Providing a 5-field Unix-style cron expression like '0 6 * * *' (no seconds field). Providing a partial expression like '0 0 12 * *' (only 5 fields). Empty or whitespace-only string passed as the cron expression. An expression with only 1-4 fields due to a copy-paste truncation.","commonSituations":"Using standard Linux crontab syntax (5 fields) which Quartz does not accept — Quartz requires a leading seconds field. Truncated expression from string manipulation or template substitution failure. Copying a cron expression from a non-Quartz system. Variable interpolation that produces fewer fields than expected.","solutions":["Ensure the expression has at least 6 fields: add a leading seconds field (usually '0') to 5-field Unix cron expressions.","Convert Unix '0 6 * * *' to Quartz '0 0 6 * * ?' (note: also change '*' in day-of-week to '?').","Validate field count before constructing the CronExpression: split by whitespace and assert length is 6 or 7.","Check for template/variable substitution issues that may truncate the expression."],"exampleFix":"// before: 5-field Unix cron (missing seconds field)\nString cron = \"0 6 * * *\";\nCronExpression expr = new CronExpression(cron);\n\n// after: 6-field Quartz cron (seconds minutes hours dom month dow)\nString cron = \"0 0 6 * * ?\";\nCronExpression expr = new CronExpression(cron);","handlingStrategy":"validation","validationCode":"// Validate minimum field count before parsing\npublic void validateCronMinFields(String expression) {\n    if (expression == null || expression.trim().isEmpty()) {\n        throw new IllegalArgumentException(\"Cron expression cannot be null or empty\");\n    }\n    int count = new StringTokenizer(expression, \" \\t\").countTokens();\n    if (count < 6) {\n        throw new IllegalArgumentException(\n            \"Cron expression must have at least 6 fields (seconds through day-of-week), found \" + count);\n    }\n}","typeGuard":"// Check expression has at least 6 whitespace-separated fields\npublic boolean hasMinCronFields(String expression) {\n    if (expression == null || expression.trim().isEmpty()) return false;\n    return new StringTokenizer(expression, \" \\t\").countTokens() >= 6;\n}","tryCatchPattern":"try {\n    CronExpression cron = new CronExpression(expression);\n} catch (ParseException e) {\n    if (e.getMessage().contains(\"Unexpected end\")) {\n        throw new IllegalArgumentException(\n            \"Cron expression is too short. Quartz requires at least 6 fields (add a seconds field).\", e);\n    }\n    throw e;\n}","preventionTips":["Always include the seconds field when writing Quartz cron expressions.","Convert 5-field Unix cron to 6-field Quartz cron by prepending '0' for seconds.","Validate field count programmatically before constructing a CronExpression.","Check for template/variable substitution issues that may truncate the expression."],"tags":["cron","quartz","scheduling","xxl-job","validation"],"backgroundTag":null,"analyzedSha":"96fb33f5ec68516da0b0147da06b2eb0419e063a","analyzedAt":"2026-08-14T00:04:16.786Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}