{"record":{"id":"717d600ce2473252","repo":"apache/hadoop","slug":"requested-read-length-is-more-than-will-fit-after","errorCode":null,"errorMessage":"requested read length is more than will fit after requested offset in buffer","messagePattern":"requested read length is more than will fit after requested offset in buffer","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":667,"sourceCode":"\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));\n      op = client.read(path, position, b, offset, length,\n          tolerateOobAppends ? \"*\" : eTag, cachedSasToken.get(),\n          contextEncryptionAdapter, tracingContext);\n\n      // Update metadata on first read if restrictGpsOnOpenFile is enabled\n      if (shouldRestrictGpsOnOpenFile() && isFirstRead()) {\n        if (client.checkIsDir(op.getResult())) {\n          throw directoryReadException();\n        }","sourceCodeStart":649,"sourceCodeEnd":685,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsInputStream.java#L649-L685","documentation":"Error \"requested read length is more than will fit after requested offset in buffer\" thrown in apache/hadoop.","triggerScenarios":"read() requests more bytes than fit in the destination array from the given offset.","commonSituations":"See trigger scenarios.","solutions":["Reduce the requested length so offset + length <= buffer.length.","Fix offset/length computations in the caller."],"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-22T20:17:22.307Z"}