{"record":{"id":"fed83ef6efc77d82","repo":"apache/hadoop","slug":"cannot-seek-at-negative-position-pos","errorCode":null,"errorMessage":"Cannot seek at negative position:{pos}","messagePattern":"Cannot seek at negative 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":91,"sourceCode":"\n    this.expectNextPos = 0;\n    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) {","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-tools/hadoop-aliyun/src/main/java/org/apache/hadoop/fs/aliyun/oss/AliyunOSSInputStream.java#L73-L109","documentation":"Error \"Cannot seek at negative position:{pos}\" thrown in apache/hadoop.","triggerScenarios":"Thrown at hadoop-tools/hadoop-aliyun/src/main/java/org/apache/hadoop/fs/aliyun/oss/AliyunOSSInputStream.java:91 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a non-negative position to seek(); fix the caller to clamp the position to 0 or greater before seeking."],"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"}