apache/hadoop · error · IllegalArgumentException

null byte array passed in to read() method

Error message

null byte array passed in to read() method

What it means

Precondition on readRemote: the destination byte array is null, so there is nowhere to place the fetched bytes; rejected before any request is issued.

Solutions

  1. Pass a non-null byte array to read().
  2. Guard against null buffers in application read loops.
Defensive patterns

Strategy: validation

When it happens

Trigger: read(byte[], int, int) is called with a null buffer.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsInputStream.java:658

  private long extractContentLength(AbfsHttpOperation op) {
    // We need to use content range header instead of content length to take care of partial reads
    String contentRange = op.getResponseHeader(HttpHeaderConfigurations.CONTENT_RANGE);
    contentLength = 0;
    if (!StringUtils.isEmpty(contentRange)) {
      contentLength = Long.parseLong(contentRange.split(AbfsHttpConstants.FORWARD_SLASH)[1]);
    }
    return contentLength;
  }

  int readRemote(long position, byte[] b, int offset, int length, TracingContext tracingContext) throws IOException {
    if (position < 0) {
      throw new IllegalArgumentException("attempting to read from negative offset");
    }
    if (!(shouldRestrictGpsOnOpenFile() && isFirstRead()) && position >= contentLength) {
      return -1;  // Hadoop prefers -1 to EOFException
    }
    if (b == null) {
      throw new IllegalArgumentException("null byte array passed in to read() method");
    }
    if (offset >= b.length) {
      throw new IllegalArgumentException("offset greater than length of array");
    }
    if (length < 0) {
      throw new IllegalArgumentException("requested read length is less than zero");
    }
    if (length > (b.length - offset)) {
      throw new IllegalArgumentException("requested read length is more than will fit after requested offset in buffer");
    }
    final AbfsRestOperation op;
    AbfsPerfTracker tracker = client.getAbfsPerfTracker();
    try (AbfsPerfInfo perfInfo = new AbfsPerfInfo(tracker, "readRemote", "read")) {
      if (streamStatistics != null) {
        streamStatistics.remoteReadOperation();
      }
      LOG.trace("Trigger client.read for path={} position={} offset={} length={}", path, position, offset, length);
      tracingContext.setPosition(String.valueOf(position));

View on GitHub (pinned to 2add963021)