apache/hadoop · error · ServiceException

null param while calling Method: [{}]

Error message

null param while calling Method: [{}]

What it means

The same ProtobufRpcEngine InvocationHandler rejects args[1] == null: a protobuf RPC always carries exactly one request Message, and null cannot be serialized to the wire format, so ServiceException('null param while calling Method: [m]') is thrown client-side before connecting. It is a pure caller bug — the request object was never built or was lost.

Source

Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/ProtobufRpcEngine.java:227

     * 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

  1. Always pass a real request Message; for empty requests use MyRequestProto.getDefaultInstance().
  2. Null-check args at the wrapper/translator boundary and fail with a clearer message.
  3. Enable the protocol's builder validation so malformed requests surface earlier.

Example fix

// before
GetFileInfoResponseProto resp = proxy.getFileInfo(null, null); // null request

// after
GetFileInfoResponseProto resp = proxy.getFileInfo(null,
    GetFileInfoRequestProto.newBuilder().setPath("/").build());
Defensive patterns

Strategy: validation

Validate before calling

// before invoking through the PB proxy
java.util.Objects.requireNonNull(requestProto,
    "request message for " + methodName + " must not be null");

Prevention

When it happens

Trigger: Passing null explicitly as the request message (proxy.method(null, null)); a builder chain that returns null on error and is forwarded unchecked; helper wrappers that accept null and blindly forward when the caller omits the request.

Common situations: Quick test code calling translators with null; Optional/defaulting logic that maps 'no request' to null instead of a default instance (Message.getDefaultInstance()); refactors that swapped argument order.

Related errors


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/905cd022400cfd84. Report an issue: GitHub.