apache/hadoop · error · IllegalArgumentException
{name} cannot be null
Error message
{name} cannot be null What it means
Check.notNull(obj, name) is the httpfs library's argument guard: it throws IllegalArgumentException('<name> cannot be null') when a caller passes null to any API parameter guarded by it (for example the 'user'/'conf' arguments of FileSystemAccess.execute and createFileSystemInternal). This is a programmer/argument error, not an environment problem.
Source
Thrown at hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/lib/util/Check.java:47
* <p>
* Commonly used for method arguments preconditions.
*/
@InterfaceAudience.Private
public class Check {
/**
* Verifies a variable is not NULL.
*
* @param obj the variable to check.
* @param name the name to use in the exception message.
*
* @return the variable.
*
* @throws IllegalArgumentException if the variable is NULL.
*/
public static <T> T notNull(T obj, String name) {
if (obj == null) {
throw new IllegalArgumentException(name + " cannot be null");
}
return obj;
}
/**
* Verifies a list does not have any NULL elements.
*
* @param list the list to check.
* @param name the name to use in the exception message.
*
* @return the list.
*
* @throws IllegalArgumentException if the list has NULL elements.
*/
public static <T> List<T> notNullElements(List<T> list, String name) {
notNull(list, name);
for (int i = 0; i < list.size(); i++) {
notNull(list.get(i), MessageFormat.format("list [{0}] element [{1}]", name, i));View on GitHub (pinned to 2add963021)
Solutions
- Look at the exception message - it names the exact argument that was null
- Fix the caller to pass a non-null value (e.g. reject requests without a user parameter with a 4xx before reaching the service)
- For 'user', validate the incoming proxy/doAs parameter at the HTTP boundary
- Add unit tests covering the missing-argument path
Example fix
// before
String user = request.getParameter("user.name");
fsAccess.execute(user, conf, executor); // null user -> IllegalArgumentException
// after
String user = request.getParameter("user.name");
if (user == null || user.isEmpty()) { throw new IllegalArgumentException("user.name required"); }
fsAccess.execute(user, conf, executor); Defensive patterns
Strategy: validation
Validate before calling
import java.util.Objects;
String user = Objects.requireNonNullElse(requestedUser, "");
if (user.isEmpty()) { throw new IllegalArgumentException("user required"); }
// only reach guarded APIs with non-null arguments
fsAccess.execute(user, Objects.requireNonNull(conf, "conf"), executor); Type guard
static boolean isUsableUser(String s) {
return s != null && !s.isEmpty();
} Try / catch
try {
fsAccess.execute(user, conf, executor);
} catch (IllegalArgumentException ex) {
// message names the null argument, e.g. 'user cannot be null' - caller bug, do not retry
throw new BadRequestException(ex.getMessage(), ex);
} Prevention
- Validate arguments at the system boundary (HTTP request parsing) before calling service APIs
- Use Objects.requireNonNull with your own message at call sites where null is a bug
- Map IllegalArgumentException from Check helpers to 4xx responses - they are client/programmer errors, never retry them
When it happens
Trigger: Calling any guarded API with a null argument, e.g. FileSystemAccess.execute(null, conf, executor) or createFileSystem(user, null); Check.notNullable-style guards run before any work starts and fail fast.
Common situations: A web layer derives the user from a request and forwards it without checking presence (missing doAs/user.name parameter); null Configuration produced by a broken config loader passed into execute(); unit tests calling the service with placeholder nulls.
Related errors
- Source must not be null
- Destination must not be null
- The filePath should not be null!
- {name} cannot be empty
- Job Priority cannot be null.
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/e622de753bb5894d.
Report an issue: GitHub.