{"record":{"id":"08feeed37de34852","repo":"apache/hadoop","slug":"not-a-bytebufferpositionedreadable-in","errorCode":null,"errorMessage":"Not a ByteBufferPositionedReadable: ${in}","messagePattern":"Not a ByteBufferPositionedReadable: (.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/wrappedio/WrappedIO.java","lineNumber":218,"sourceCode":"   * @throws IOException early checks like failure to resolve path cause IO failures\n   */\n  public static Path fileSystem_getEnclosingRoot(FileSystem fs, Path path) throws IOException {\n    return fs.getEnclosingRoot(path);\n  }\n\n  /**\n   * Delegate to {@link ByteBufferPositionedReadable#read(long, ByteBuffer)}.\n   * @param in input stream\n   * @param position position within file\n   * @param buf the ByteBuffer to receive the results of the read operation.\n   * Note: that is the default behaviour of {@link FSDataInputStream#readFully(long, ByteBuffer)}.\n   */\n  public static void byteBufferPositionedReadable_readFully(\n      InputStream in,\n      long position,\n      ByteBuffer buf) {\n    if (!(in instanceof ByteBufferPositionedReadable)) {\n      throw new UnsupportedOperationException(\"Not a ByteBufferPositionedReadable: \" + in);\n    }\n    uncheckIOExceptions(() -> {\n      ((ByteBufferPositionedReadable) in).readFully(position, buf);\n      return null;\n    });\n  }\n\n  /**\n   * Probe to see if the input stream is an instance of ByteBufferPositionedReadable.\n   * If the stream is an FSDataInputStream, the wrapped stream is checked.\n   * @param in input stream\n   * @return true if the stream implements the interface (including a wrapped stream)\n   * and that it declares the stream capability.\n   */\n  public static boolean byteBufferPositionedReadable_readFullyAvailable(\n      InputStream in) {\n    if (!(in instanceof ByteBufferPositionedReadable)) {\n      return false;","sourceCodeStart":200,"sourceCodeEnd":236,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/wrappedio/WrappedIO.java#L200-L236","documentation":"WrappedIO.byteBufferPositionedReadable_readFully(InputStream, long, ByteBuffer) delegates positional byte-buffer (vectored) reads to ByteBufferPositionedReadable.readFully. It performs a strict `in instanceof ByteBufferPositionedReadable` check and throws UnsupportedOperationException when the stream passed in does not directly implement that interface. Note that unlike the companion probe byteBufferPositionedReadable_readFullyAvailable (WrappedIO.java:233), this method does NOT unwrap FSDataInputStream, so passing an FSDataInputStream itself always fails because that wrapper class does not implement the interface.","triggerScenarios":"Calling WrappedIO.byteBufferPositionedReadable_readFully with: (a) an FSDataInputStream instead of its underlying getWrappedStream(); (b) a plain java.io stream such as FileInputStream, ByteArrayInputStream, or an HTTP stream; (c) a filesystem-specific stream that lacks the StreamCapabilities.PREADBYTEBUFFER capability (local raw files, older object-store connectors).","commonSituations":"Columnar readers (Parquet/ORC) routed through WrappedIO reading from filesystems without vectored-IO support; mixing Hadoop artifact versions where the connector predates ByteBufferPositionedReadable; passing fs.open(path) directly instead of fs.open(path).getWrappedStream().","solutions":["Probe first: if (WrappedIO.byteBufferPositionedReadable_readFullyAvailable(in)) — it unwraps FSDataInputStream and verifies the in:preadbytebuffer stream capability before you call the read.","If the probe returns true for an FSDataInputStream, pass ((FSDataInputStream) in).getWrappedStream() to byteBufferPositionedReadable_readFully.","If the filesystem lacks the capability, fall back to byte-array positioned reads: FSDataInputStream.readFully(position, buf.array(), buf.arrayOffset() + buf.position(), remaining).","Upgrade the filesystem connector (hadoop-hdfs-client, S3A, ABFS) to a version whose input streams implement ByteBufferPositionedReadable."],"exampleFix":"// before\ntry (FSDataInputStream in = fs.open(path)) {\n  WrappedIO.byteBufferPositionedReadable_readFully(in, pos, buf); // throws: FSDataInputStream is not a ByteBufferPositionedReadable\n}\n\n// after\ntry (FSDataInputStream in = fs.open(path)) {\n  if (WrappedIO.byteBufferPositionedReadable_readFullyAvailable(in)) {\n    WrappedIO.byteBufferPositionedReadable_readFully(\n        in.getWrappedStream(), pos, buf);\n  } else {\n    in.readFully(pos, buf.array(), buf.arrayOffset() + buf.position(), buf.remaining());\n    buf.position(buf.position() + buf.remaining());\n  }\n}","handlingStrategy":"type-guard","validationCode":"import org.apache.hadoop.io.wrappedio.WrappedIO;\nimport org.apache.hadoop.fs.FSDataInputStream;\n\nboolean canVectoredPread(InputStream in) {\n  return WrappedIO.byteBufferPositionedReadable_readFullyAvailable(in); // unwraps FSDataInputStream + checks in:preadbytebuffer\n}","typeGuard":"static boolean isByteBufferPositionedReadable(InputStream in) {\n  if (in instanceof FSDataInputStream) {\n    in = ((FSDataInputStream) in).getWrappedStream();\n  }\n  return in instanceof org.apache.hadoop.fs.ByteBufferPositionedReadable;\n}","tryCatchPattern":"try {\n  WrappedIO.byteBufferPositionedReadable_readFully(rawStream, pos, buf);\n} catch (UnsupportedOperationException e) {\n  // stream lacks vectored pread; fall back to byte-array positioned read\n  fdis.readFully(pos, buf.array(), buf.arrayOffset() + buf.position(), buf.remaining());\n}","preventionTips":["Always gate the call with byteBufferPositionedReadable_readFullyAvailable(in).","Pass getWrappedStream() for FSDataInputStream instances, never the wrapper.","Keep hadoop-client artifacts version-aligned so stream implementations carry the interface.","Design readers with a byte-array positional-read fallback path."],"tags":["hadoop","wrappedio","vectored-io","bytebuffer","stream-capability","unsupported-operation","input-stream"],"backgroundTag":"stream-capability-unsupported","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}