{"record":{"id":"aed05fa249902a58","repo":"apache/hadoop","slug":"reset-not-supported","errorCode":null,"errorMessage":"reset not supported","messagePattern":"reset not supported","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"warning","filePath":"hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/prefetch/S3ARemoteInputStream.java","lineNumber":478,"sourceCode":"\n  protected void throwIfInvalidSeek(long pos) throws EOFException {\n    if (pos < 0) {\n      throw new EOFException(FSExceptionMessages.NEGATIVE_SEEK + \" \" + pos);\n    } else if (pos > this.getBlockData().getFileSize()) {\n      throw new EOFException(FSExceptionMessages.CANNOT_SEEK_PAST_EOF + \" \" + pos);\n    }\n  }\n\n  // Unsupported functions.\n\n  @Override\n  public void mark(int readlimit) {\n    throw new UnsupportedOperationException(\"mark not supported\");\n  }\n\n  @Override\n  public void reset() {\n    throw new UnsupportedOperationException(\"reset not supported\");\n  }\n\n  @Override\n  public long skip(long n) {\n    throw new UnsupportedOperationException(\"skip not supported\");\n  }\n}\n","sourceCodeStart":460,"sourceCodeEnd":486,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/prefetch/S3ARemoteInputStream.java#L460-L486","documentation":"S3ARemoteInputStream.reset() always throws UnsupportedOperationException(\"reset not supported\") - the counterpart to mark() being unsupported. The prefetcher's remote input stream is repositioned exclusively via seek(); the java.io mark/reset protocol is intentionally not implemented.","triggerScenarios":"Calling reset() after a previous mark() (which itself throws); library code that calls reset() when markSupported() returns false, violating the InputStream contract; generic parsing utilities applying mark/reset idiomatically.","commonSituations":"Handing the raw stream to parsers (JSON/CSV/avro readers) that reset to re-read; test helpers; wrapping layers that propagate reset() blindly.","solutions":["Never call reset() on S3ARemoteInputStream; save getPos() and seek(pos) to return.","Wrap in BufferedInputStream when a component genuinely needs mark/reset.","Guard shared code with if (stream.markSupported()) before using mark/reset.","Operate on the public FSDataInputStream, which offers seek-based repositioning."],"exampleFix":"// before\nlong p = stream.getPos();\nstream.mark(1024); // throws first\nstream.reset();     // would throw too\n\n// after\nlong p = stream.getPos();\n... read ahead ...\nstream.seek(p); // reposition without mark/reset","handlingStrategy":"validation","validationCode":"if (stream.markSupported()) {\n  stream.reset();\n} else {\n  stream.seek(markPos); // saved from getPos() earlier\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only call reset() after a successful mark() on a stream where markSupported() is true.","Save/restore positions with getPos()/seek() on seekable Hadoop streams.","Isolate third-party parsers behind a BufferedInputStream wrapper."],"tags":["hadoop-aws","prefetch","unsupported-operation","mark-reset"],"backgroundTag":"unsupported-operation-exception","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}