apache/hadoop · error · ServiceException
null param while calling Method: [{}]
Error message
null param while calling Method: [{}] What it means
ProtobufRpcEngine2's InvocationHandler rejects a null request message (args[1] == null) with ServiceException('null param while calling Method: [m]') because protobuf messages cannot be null on the wire — there is always at least a default instance. Thrown client-side, before a connection is made.
Source
Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/ProtobufRpcEngine2.java:236
* cause is RemoteException, then unwrap it to get the exception thrown by
* the server.
*/
@Override
public Message invoke(Object proxy, final Method method, Object[] args)
throws ServiceException {
long startTime = 0;
if (LOG.isDebugEnabled()) {
startTime = Time.monotonicNow();
}
if (args.length != 2) { // RpcController + Message
throw new ServiceException(
"Too many or few parameters for request. Method: ["
+ method.getName() + "]" + ", Expected: 2, Actual: "
+ args.length);
}
if (args[1] == null) {
throw new ServiceException("null param while calling Method: ["
+ method.getName() + "]");
}
// if Tracing is on then start a new span for this rpc.
// guard it in the if statement to make sure there isn't
// any extra string manipulation.
Tracer tracer = Tracer.curThreadTracer();
TraceScope traceScope = null;
if (tracer != null) {
traceScope = tracer.newScope(RpcClientUtil.methodToTraceString(method));
}
if (LOG.isTraceEnabled()) {
LOG.trace(Thread.currentThread().getId() + ": Call -> " +
remoteId + ": " + method.getName() +
" {" + TextFormat.shortDebugString((Message) args[1]) + "}");
}
View on GitHub (pinned to 2add963021)
Solutions
- Pass Message.getDefaultInstance() for 'empty' requests.
- Make request-builder helpers never return null — throw or return the default instance.
- Add Objects.requireNonNull(request) at the wrapper boundary for a clearer failure.
Example fix
// before
proxy.rename(null, null); // null request -> ServiceException
// after
proxy.rename(null,
RenameRequestProto.newBuilder()
.setSrc("/a").setDst("/b").build()); Defensive patterns
Strategy: validation
Validate before calling
java.util.Objects.requireNonNull(request,
"protobuf request for " + method.getName() + " must not be null; use getDefaultInstance() if empty"); Prevention
- Never forward possibly-null messages; substitute the default instance.
- Use builder-helper APIs that always yield a built message.
- Objects.requireNonNull at the boundary gives a better stack than the engine's generic error.
When it happens
Trigger: Calling proxy.method(controller, null); a request-builder helper returning null on validation failure and being forwarded; argument-order mix-ups where null lands in the message slot.
Common situations: Test harnesses stubbing request construction; wrapper APIs with optional parameters defaulted to null; refactors from WritableRpcEngine (where null params were sometimes tolerated) to protobuf.
Related errors
- null param while calling Method: [{}]
- Null protocol
- Too many or few parameters for request. Method: [{}], Expect
- Unknown method {} called on {} protocol.
- Too many or few parameters for request. Method: [{}], Expect
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/6929c98a471918d7.
Report an issue: GitHub.