elastic/elasticsearch · error · NullPointerException
${name} ${description} was null
Error message
${name} ${description} was null What it means
AbstractLazyPropertyCollection is the base for Gradle lazy property containers (e.g. dependency/module lists). assertNotNull is called by subclasses when normalising their collection; if a caller passed null for a required element the method throws a NullPointerException naming the collection, the description of the offending argument, and the owner being configured if known.
Source
Thrown at build-tools/src/main/java/org/elasticsearch/gradle/AbstractLazyPropertyCollection.java:31
public abstract class AbstractLazyPropertyCollection {
final String name;
final Object owner;
public AbstractLazyPropertyCollection(String name) {
this(name, null);
}
public AbstractLazyPropertyCollection(String name, Object owner) {
this.name = name;
this.owner = owner;
}
public abstract List<? extends Object> getNormalizedCollection();
void assertNotNull(Object value, String description) {
if (value == null) {
throw new NullPointerException(name + " " + description + " was null" + (owner != null ? " when configuring " + owner : ""));
}
}
}
View on GitHub (pinned to db6a809a66)
Solutions
- Read the message: it states which collection and which description was null, plus the owner.
- Filter or default the value before adding: `Optional.ofNullable(x).ifPresent(coll::add)`.
- Fix the upstream provider so it never supplies null — set a convention or use a Property.
Example fix
// before collection.add(maybeNullProvider.getOrNull()) // after Optional.ofNullable(maybeNullProvider.getOrNull()).ifPresent(collection::add)
Defensive patterns
Strategy: type-guard
Validate before calling
static <T> void addIfPresent(AbstractLazyPropertyCollection coll, T value, String description) {
if (value == null) {
throw new NullPointerException(coll + " " + description + " was null");
}
// coll.add(value) — guarded
} Type guard
static <T> boolean isAddable(T value) {
return value != null;
} Try / catch
try {
collection.add(value);
} catch (NullPointerException npe) {
if (npe.getMessage().contains("was null")) {
getLogger().warn("Skipping null element: {}", npe.getMessage());
} else { throw npe; }
} Prevention
- Filter nulls out of collections before adding (use Optional/Stream).
- Give lazy collections an owner at construction so NPE messages name the configuring object.
- Prefer Gradle Provider/Property over raw values that may be null.
When it happens
Trigger: Invoking an add/with method on a lazy collection subclass with a null element while the subclass delegates through assertNotNull(value, description). The owner context is appended only when the collection was constructed with an owner.
Common situations: A build plugin call like dependencies.add(null) or a convention that forwards a possibly-null provider value; a refactor that removed a provider's convention without a fallback; a third-party plugin integrating with ES build tools passing null.
Related errors
- Elasticsearch version is missing from properties.
- Expected elasticsearch version to be numbers only of the for
- Invalid qualifier: ${qualifier}
- build.snapshot was set to [${buildSnapshotSystemProperty}] b
- Sysprop [${property}] must be [true] or [false] but was [${p
AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12).
Data as JSON: /api/errors/5ada4a889ec83acc.
Report an issue: GitHub.