{"record":{"id":"0227b16d4248066e","repo":"apache/hadoop","slug":"cannot-seek-after-eof-contentlength-contentlengt","errorCode":null,"errorMessage":"Cannot seek after EOF, contentLength:{contentLength} position:{pos}","messagePattern":"Cannot seek after EOF, contentLength:(.+?) position:(.+?)","errorType":"exception","errorClass":"EOFException","httpStatus":null,"severity":"error","filePath":"hadoop-tools/hadoop-aliyun/src/main/java/org/apache/hadoop/fs/aliyun/oss/AliyunOSSInputStream.java","lineNumber":93,"sourceCode":"    this.lastByteStart = -1;\n    reopen(0);\n    closed = false;\n  }\n\n  /**\n   * Reopen the wrapped stream at give position, by seeking for\n   * data of a part length from object content stream.\n   *\n   * @param pos position from start of a file\n   * @throws IOException if failed to reopen\n   */\n  private synchronized void reopen(long pos) throws IOException {\n    long partSize;\n\n    if (pos < 0) {\n      throw new EOFException(\"Cannot seek at negative position:\" + pos);\n    } else if (pos > contentLength) {\n      throw new EOFException(\"Cannot seek after EOF, contentLength:\" +\n          contentLength + \" position:\" + pos);\n    } else if (pos + downloadPartSize > contentLength) {\n      partSize = contentLength - pos;\n    } else {\n      partSize = downloadPartSize;\n    }\n\n    if (this.buffer != null) {\n      if (LOG.isDebugEnabled()) {\n        LOG.debug(\"Aborting old stream to open at pos \" + pos);\n      }\n      this.buffer = null;\n    }\n\n    boolean isRandomIO = true;\n    if (pos == this.expectNextPos) {\n      isRandomIO = false;\n    } else {","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-tools/hadoop-aliyun/src/main/java/org/apache/hadoop/fs/aliyun/oss/AliyunOSSInputStream.java#L75-L111","documentation":"Error \"Cannot seek after EOF, contentLength:{contentLength} position:{pos}\" thrown in apache/hadoop.","triggerScenarios":"Thrown at hadoop-tools/hadoop-aliyun/src/main/java/org/apache/hadoop/fs/aliyun/oss/AliyunOSSInputStream.java:93 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Do not seek beyond the file length; check contentLength and limit the requested position to be within [0, contentLength]."],"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"}