{"record":{"id":"dceabb8413458fe3","repo":"apache/hadoop","slug":"classname-is-not-an-instance-of-seekable-or-pos","errorCode":null,"errorMessage":"${className} is not an instance of Seekable or PositionedReadable","messagePattern":"(.+?) is not an instance of Seekable or PositionedReadable","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FSDataInputStream.java","lineNumber":62,"sourceCode":"@InterfaceAudience.Public\n@InterfaceStability.Stable\npublic class FSDataInputStream extends DataInputStream\n    implements Seekable, PositionedReadable, \n      ByteBufferReadable, HasFileDescriptor, CanSetDropBehind, CanSetReadahead,\n      HasEnhancedByteBufferAccess, CanUnbuffer, StreamCapabilities,\n      ByteBufferPositionedReadable, IOStatisticsSource {\n  /**\n   * Map ByteBuffers that we have handed out to readers to ByteBufferPool \n   * objects\n   */\n  private final IdentityHashStore<ByteBuffer, ByteBufferPool>\n    extendedReadBuffers\n      = new IdentityHashStore<>(0);\n\n  public FSDataInputStream(InputStream in) {\n    super(in);\n    if( !(in instanceof Seekable) || !(in instanceof PositionedReadable) ) {\n      throw new IllegalArgumentException(in.getClass().getCanonicalName() +\n          \" is not an instance of Seekable or PositionedReadable\");\n    }\n  }\n  \n  /**\n   * Seek to the given offset.\n   *\n   * @param desired offset to seek to\n   */\n  @Override\n  public void seek(long desired) throws IOException {\n    ((Seekable)in).seek(desired);\n  }\n\n  /**\n   * Get the current position in the input stream.\n   *\n   * @return current position in the input stream","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FSDataInputStream.java#L44-L80","documentation":"Thrown from the FSDataInputStream constructor when the wrapped stream implements neither Seekable nor PositionedReadable. FSDataInputStream's contract requires at least one of those interfaces, so the incompatible inner stream class is named and rejected.","triggerScenarios":"Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FSDataInputStream.java:62 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Wrap the stream only if the underlying stream implements Seekable or PositionedReadable.","Use a filesystem open() call that returns a compliant stream instead of wrapping an arbitrary InputStream."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}