github-advanced-security[bot] commented on code in PR #18026:
URL:
https://github.com/apache/dolphinscheduler/pull/18026#discussion_r2898528462
##########
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parser/TimePlaceholderUtils.java:
##########
@@ -649,19 +648,21 @@
if (expression.contains("+")) {
int index = expression.lastIndexOf('+');
- if (Character.isDigit(expression.charAt(index + 1))) {
- String addMinuteExpr = expression.substring(index + 1);
- Date targetDate = addMinutes(date, calcMinutes(addMinuteExpr));
+ if (index + 1 < expression.length() &&
Character.isDigit(expression.charAt(index + 1))) {
+ String addDayExpr = expression.substring(index + 1);
+ int days = Integer.parseInt(addDayExpr);
Review Comment:
## Missing catch of NumberFormatException
Potential uncaught 'java.lang.NumberFormatException'.
[Show more
details](https://github.com/apache/dolphinscheduler/security/code-scanning/5620)
##########
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parser/TimePlaceholderUtils.java:
##########
@@ -649,19 +648,21 @@
if (expression.contains("+")) {
int index = expression.lastIndexOf('+');
- if (Character.isDigit(expression.charAt(index + 1))) {
- String addMinuteExpr = expression.substring(index + 1);
- Date targetDate = addMinutes(date, calcMinutes(addMinuteExpr));
+ if (index + 1 < expression.length() &&
Character.isDigit(expression.charAt(index + 1))) {
+ String addDayExpr = expression.substring(index + 1);
+ int days = Integer.parseInt(addDayExpr);
+ Date targetDate = addDays(date, days);
String dateFormat = expression.substring(0, index);
return new AbstractMap.SimpleImmutableEntry<>(targetDate,
dateFormat);
}
} else if (expression.contains("-")) {
int index = expression.lastIndexOf('-');
- if (Character.isDigit(expression.charAt(index + 1))) {
- String addMinuteExpr = expression.substring(index + 1);
- Date targetDate = addMinutes(date, 0 -
calcMinutes(addMinuteExpr));
+ if (index + 1 < expression.length() &&
Character.isDigit(expression.charAt(index + 1))) {
+ String addDayExpr = expression.substring(index + 1);
+ int days = Integer.parseInt(addDayExpr);
Review Comment:
## Missing catch of NumberFormatException
Potential uncaught 'java.lang.NumberFormatException'.
[Show more
details](https://github.com/apache/dolphinscheduler/security/code-scanning/5621)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]