apache/druid · error · java.lang.IllegalArgumentException

Empty list of intervals

Error message

Empty list of intervals

What it means

JodaUtils.umbrellaInterval computes the smallest interval covering all given intervals; it throws IllegalArgumentException ('Empty list of intervals') when the iterable yields no elements, because no umbrella interval can exist for an empty set. Note this uses plain IllegalArgumentException, not IAE formatting, and cannot be avoided by passing default values.

Solutions

  1. Check the collection is non-empty before calling: if (!intervals.iterator().hasNext()) return null / a default interval
  2. Provide a sensible fallback interval (e.g. Universal interval 1970/2100) when the list can legitimately be empty
  3. Fix the upstream query/filter that unexpectedly produced zero intervals

Example fix

// before
Interval umbrella = JodaUtils.umbrellaInterval(intervals); // throws when empty
// after
Interval umbrella = intervals.isEmpty() ? null : JodaUtils.umbrellaInterval(intervals);
Defensive patterns

Strategy: validation

Validate before calling

if (intervals == null || intervals.isEmpty()) {
  return null; // or a default umbrella interval
}

Type guard

static Interval safeUmbrella(List<Interval> intervals, Interval fallback) {
  return intervals.isEmpty() ? fallback : JodaUtils.umbrellaInterval(intervals);
}

Try / catch

try {
  return JodaUtils.umbrellaInterval(intervals);
} catch (IllegalArgumentException e) {
  log.warn("No intervals to umbrella; using full range");
  return new Interval(0, Long.MAX_VALUE);
}

Prevention

When it happens

Trigger: Calling umbrellaInterval(Collections.emptyList()) or with a collection filtered down to nothing (e.g. all intervals removed by a null/validity filter before the call).

Common situations: Computing the time range of a datasource or task run whose interval list came back empty (no segments ingested yet, fully filtered results); aggregating intervals across shards where some shards had none.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07). Data as JSON: /api/errors/ad7dac3ca232574c. Report an issue: GitHub.

Appendix: source

Thrown at processing/src/main/java/org/apache/druid/java/util/common/JodaUtils.java:181

      throw new IAE("Adjacent intervals are not sorted [%s,%s]", previous, current);
    }
  }

  public static Interval umbrellaInterval(Iterable<Interval> intervals)
  {
    boolean emptyIntervals = true;
    DateTimeComparator dateTimeComp = DateTimeComparator.getInstance();
    DateTime minStart = new DateTime(Long.MAX_VALUE, ISOChronology.getInstanceUTC());
    DateTime maxEnd = new DateTime(Long.MIN_VALUE, ISOChronology.getInstanceUTC());

    for (Interval interval : intervals) {
      emptyIntervals = false;
      minStart = Collections.min(ImmutableList.of(minStart, interval.getStart()), dateTimeComp);
      maxEnd = Collections.max(ImmutableList.of(maxEnd, interval.getEnd()), dateTimeComp);
    }

    if (emptyIntervals) {
      throw new IllegalArgumentException("Empty list of intervals");
    }
    return new Interval(minStart, maxEnd);
  }

  public static DateTime minDateTime(DateTime... times)
  {
    if (times == null) {
      return null;
    }

    switch (times.length) {
      case 0:
        return null;
      case 1:
        return times[0];
      default:
        DateTime min = times[0];
        for (int i = 1; i < times.length; ++i) {

View on GitHub (pinned to 9b90983fd2)