{"record":{"id":"c5cd1bffe0c7e471","repo":"apache/hadoop","slug":"mark-not-supported","errorCode":null,"errorMessage":"Mark not supported","messagePattern":"Mark not supported","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/ftp/FTPInputStream.java","lineNumber":137,"sourceCode":"          + client.getReplyCode());\n    }\n  }\n\n  // Not supported.\n\n  @Override\n  public boolean markSupported() {\n    return false;\n  }\n\n  @Override\n  public void mark(int readLimit) {\n    // Do nothing\n  }\n\n  @Override\n  public void reset() throws IOException {\n    throw new IOException(\"Mark not supported\");\n  }\n}\n","sourceCodeStart":119,"sourceCodeEnd":140,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/ftp/FTPInputStream.java#L119-L140","documentation":"FTPInputStream.markSupported() returns false and mark() is deliberately a no-op, so reset() always throws IOException(\"Mark not supported\") — over a sequential FTP data stream there is no buffered position to rewind to.","triggerScenarios":"Wrapping code that marks/resets: java.util.Scanner over the raw stream, pull parsers that backtrack, or application code calling mark() then reset() and not noticing mark() silently did nothing.","commonSituations":"Passing the raw FTP stream to parsers requiring mark/reset; generic utilities that ignore markSupported(); porting local-file parsing code to ftp:// paths.","solutions":["Wrap in a BufferedInputStream sized for the parser's lookahead and mark/reset only through the wrapper","Check markSupported() before mark/reset and fail with a clear message otherwise","Buffer the whole payload (read into byte[]) when small and random re-reads are needed","Best: copy to local/HDFS and parse from there"],"exampleFix":"// before\ntry (FSDataInputStream in = fs.open(path)) {\n  in.mark(1 << 16);\n  parseSome(in);\n  in.reset();               // IOException: Mark not supported\n}\n\n// after\ntry (BufferedInputStream in = new BufferedInputStream(fs.open(path), 1 << 16)) {\n  if (!in.markSupported()) { throw new IllegalStateException(\"need mark/reset\"); }\n  in.mark(1 << 16);\n  parseSome(in);\n  in.reset();               // served from the buffer\n}","handlingStrategy":"validation","validationCode":"InputStream toParse = fs.open(path);\nif (!toParse.markSupported()) {\n  toParse = new BufferedInputStream(toParse, 1 << 16);  // provide mark/reset via buffering\n}\n// safe: markSupported() is now guaranteed true before any mark/reset","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check markSupported() before mark/reset on any wrapped stream","Feed parsers a BufferedInputStream, never the raw FTP stream","For small files, read fully into memory and parse from the byte array"],"tags":["ftp","hadoop","input-stream","mark-reset","unsupported-operation"],"backgroundTag":"mark-reset-unsupported","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}