{"record":{"id":"78a4693e2e14bf56","repo":"apache/hadoop","slug":"offset-greater-than-length-of-array","errorCode":null,"errorMessage":"offset greater than length of array","messagePattern":"offset greater than length of array","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":661,"sourceCode":"    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));\n      op = client.read(path, position, b, offset, length,\n          tolerateOobAppends ? \"*\" : eTag, cachedSasToken.get(),\n          contextEncryptionAdapter, tracingContext);","sourceCodeStart":643,"sourceCodeEnd":679,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsInputStream.java#L643-L679","documentation":"Error \"offset greater than length of array\" thrown in apache/hadoop.","triggerScenarios":"read() is called with an offset beyond the end of the destination array.","commonSituations":"See trigger scenarios.","solutions":["Ensure the offset is less than the destination array length.","Check offset/length arithmetic in the calling code."],"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"}