apache/hadoop · error · IllegalArgumentException
Null opt
Error message
Null opt
What it means
Options.CreateOpts.getOpt(clazz, opts) requires a non-null varargs array of create options. Passing null (the array itself, not an element) throws IllegalArgumentException('Null opt') before scanning.
Source
Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Options.java:171
public static class CreateParent extends CreateOpts {
private final boolean createParent;
protected CreateParent(boolean createPar) {
createParent = createPar;}
public boolean getValue() { return createParent; }
}
/**
* Get an option of desired type
* @param clazz is the desired class of the opt
* @param opts - not null - at least one opt must be passed
* @return an opt from one of the opts of type theClass.
* returns null if there isn't any
*/
static <T extends CreateOpts> T getOpt(Class<T> clazz, CreateOpts... opts) {
if (opts == null) {
throw new IllegalArgumentException("Null opt");
}
T result = null;
for (int i = 0; i < opts.length; ++i) {
if (opts[i].getClass() == clazz) {
if (result != null) {
throw new IllegalArgumentException("multiple opts varargs: " + clazz);
}
@SuppressWarnings("unchecked")
T t = (T)opts[i];
result = t;
}
}
return result;
}
/**
* set an option
* @param newValue the option to be setView on GitHub (pinned to 2add963021)
Solutions
- Pass an empty array (new CreateOpts[0]) instead of null
- Fix option-array builders to never return null; return an empty array
Example fix
// before T opt = CreateOpts.getOpt(clazz, null); // after T opt = CreateOpts.getOpt(clazz, new CreateOpts[0]); // never pass a null varargs array
Defensive patterns
Strategy: validation
Validate before calling
CreateOpts[] safe = (opts == null) ? new CreateOpts[0] : opts;
Prevention
- Never pass null for a varargs array; use an empty array
- Make option-array builders return empty arrays, not null
- Flag null literals passed to varargs parameters in review
When it happens
Trigger: Calling getOpt with an explicitly null CreateOpts... array — e.g. a caller built its option array conditionally and the builder returned null, or reflection/bridging code passed null through.
Common situations: Helper APIs assembling option arrays that default to null, defensive `opts != null ? opts : null` bugs, conditional builder methods.
Related errors
- Permissions must not be null
- Progress must not be null
- multiple opts varargs: ${clazz}
- tokenStr cannot be null
- url cannot be NULL
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/2f7517ad91c8df1d.
Report an issue: GitHub.