{"record":{"id":"fc57520027f0d066","repo":"apache/hadoop","slug":"null-byte-array-passed-in-to-read-method","errorCode":null,"errorMessage":"null byte array passed in to read() method","messagePattern":"null byte array passed in to read\\(\\) method","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsInputStream.java","lineNumber":658,"sourceCode":"  private long extractContentLength(AbfsHttpOperation op) {\n    // We need to use content range header instead of content length to take care of partial reads\n    String contentRange = op.getResponseHeader(HttpHeaderConfigurations.CONTENT_RANGE);\n    contentLength = 0;\n    if (!StringUtils.isEmpty(contentRange)) {\n      contentLength = Long.parseLong(contentRange.split(AbfsHttpConstants.FORWARD_SLASH)[1]);\n    }\n    return contentLength;\n  }\n\n  int readRemote(long position, byte[] b, int offset, int length, TracingContext tracingContext) throws IOException {\n    if (position < 0) {\n      throw new IllegalArgumentException(\"attempting to read from negative offset\");\n    }\n    if (!(shouldRestrictGpsOnOpenFile() && isFirstRead()) && position >= contentLength) {\n      return -1;  // Hadoop prefers -1 to EOFException\n    }\n    if (b == null) {\n      throw new IllegalArgumentException(\"null byte array passed in to read() method\");\n    }\n    if (offset >= b.length) {\n      throw new IllegalArgumentException(\"offset greater than length of array\");\n    }\n    if (length < 0) {\n      throw new IllegalArgumentException(\"requested read length is less than zero\");\n    }\n    if (length > (b.length - offset)) {\n      throw new IllegalArgumentException(\"requested read length is more than will fit after requested offset in buffer\");\n    }\n    final AbfsRestOperation op;\n    AbfsPerfTracker tracker = client.getAbfsPerfTracker();\n    try (AbfsPerfInfo perfInfo = new AbfsPerfInfo(tracker, \"readRemote\", \"read\")) {\n      if (streamStatistics != null) {\n        streamStatistics.remoteReadOperation();\n      }\n      LOG.trace(\"Trigger client.read for path={} position={} offset={} length={}\", path, position, offset, length);\n      tracingContext.setPosition(String.valueOf(position));","sourceCodeStart":640,"sourceCodeEnd":676,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsInputStream.java#L640-L676","documentation":"Error \"null byte array passed in to read() method\" thrown in apache/hadoop.","triggerScenarios":"read(byte[], int, int) is called with a null buffer.","commonSituations":"See trigger scenarios.","solutions":["Pass a non-null byte array to read().","Guard against null buffers in application read loops."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}