apache/dolphinscheduler · error · IllegalArgumentException
The date must not be null
Error message
The date must not be null
What it means
DateUtils.add is a null-safe guard around java.util.Calendar date arithmetic (a commons-lang style utility). It throws IllegalArgumentException("The date must not be null") when the date argument is null, before creating a Calendar and applying the calendarField/amount adjustment.
Source
Thrown at dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/DateUtils.java:547
* get current date
*
* @return current date
*/
public static Date getCurrentDate() {
return new Date();
}
/**
* get date
*
* @param date date
* @param calendarField calendarField
* @param amount amount
* @return date
*/
public static Date add(final Date date, final int calendarField, final int amount) {
if (date == null) {
throw new IllegalArgumentException("The date must not be null");
}
final Calendar c = Calendar.getInstance();
c.setTime(date);
c.add(calendarField, amount);
return c.getTime();
}
/**
* starting from the current time, get how many seconds are left before the target time.
* targetTime = baseTime + intervalSeconds
*
* @param baseTime base time
* @param intervalSeconds a period of time
* @return the number of seconds
*/
public static long getRemainTime(Date baseTime, long intervalSeconds) {
if (baseTime == null) {
return 0;View on GitHub (pinned to 02eac45a1b)
Solutions
- Check the date for null before calling and use a sensible default (e.g. new Date() or a fixed epoch)
- Trace the caller (addMonths/addDays/addMinutes) to find which upstream value is null and fix it at the source (e.g. handle the 'not yet finished' case explicitly)
- If null means 'not applicable', skip the date computation rather than defaulting
- When the value comes from a DB/entity field, make the column NOT NULL or use Optional at the mapping layer
Example fix
// before
Date deadline = DateUtils.addMinutes(endTime, 30); // NPE-ish IAE when endTime == null
// after
Date deadline = endTime != null
? DateUtils.addMinutes(endTime, 30)
: DateUtils.addMinutes(new Date(), 30); Defensive patterns
Strategy: type-guard
Validate before calling
if (date == null) {
throw new IllegalArgumentException("endTime must be set before computing deadline");
} Type guard
static Date requireDate(Date d) {
if (d == null) throw new IllegalArgumentException("The date must not be null");
return d;
}
// usage: DateUtils.addMinutes(requireDate(endTime), 30) Try / catch
try {
Date later = DateUtils.addDays(date, 1);
} catch (IllegalArgumentException e) {
if ("The date must not be null".equals(e.getMessage())) {
log.warn("Skipping date computation: source date is null");
} else throw e;
} Prevention
- Null-check dates from nullable entity fields (e.g. unfinished instance end times) before arithmetic
- Use Optional<Date> at the API boundary for nullable timestamps
- Enforce NOT NULL on DB columns that feed date math
- Wrap addMonths/addDays/addMinutes calls in helpers that apply defaults
When it happens
Trigger: Calling add(date, field, amount) with a null Date — directly, or indirectly via the convenience wrappers addMonths, addDays, or addMinutes, which forward their date argument unchanged.
Common situations: Computing schedule/timeout times from a nullable upstream value (e.g. a process instance end time that is null for still-running instances); DB column being NULL so the mapped Date is null; calling addMinutes(new Date()) with a typo'd variable that is uninitialized/null.
Related errors
- data: %s should be a validate data string - yyyy-MM-dd HH:mm
- Cannot format the date
- Unsupported placeholder expression:
- 10134
- remote.logging.google.cloud.storage.bucket.name is blank
AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06).
Data as JSON: /api/errors/8ec88139e44a9a88.
Report an issue: GitHub.