{"record":{"id":"5301c288216aee5f","repo":"apache/hadoop","slug":"not-support-enhanced-byte-buffer-access","errorCode":null,"errorMessage":"Not support enhanced byte buffer access.","messagePattern":"Not support enhanced byte buffer access\\.","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSStripedInputStream.java","lineNumber":569,"sourceCode":"        DFSClient.LOG.warn(Arrays.toString(nodes) + \" are unavailable and \" +\n            \"all striping blocks on them are lost. \" +\n            \"IgnoredNodes = {}\", ignoredNodes);\n        warnedNodes.addAll(dnUUIDs);\n      }\n    } else {\n      super.reportLostBlock(lostBlock, ignoredNodes);\n    }\n  }\n\n  /**\n   * May need online read recovery, zero-copy read doesn't make\n   * sense, so don't support it.\n   */\n  @Override\n  public synchronized ByteBuffer read(ByteBufferPool bufferPool,\n      int maxLength, EnumSet<ReadOption> opts)\n          throws IOException, UnsupportedOperationException {\n    throw new UnsupportedOperationException(\n        \"Not support enhanced byte buffer access.\");\n  }\n\n  @Override\n  public synchronized void releaseBuffer(ByteBuffer buffer) {\n    throw new UnsupportedOperationException(\n        \"Not support enhanced byte buffer access.\");\n  }\n\n  @Override\n  public synchronized void unbuffer() {\n    super.unbuffer();\n    if (curStripeBuf != null) {\n      BUFFER_POOL.putBuffer(curStripeBuf);\n      curStripeBuf = null;\n    }\n    if (parityBuf != null) {\n      BUFFER_POOL.putBuffer(parityBuf);","sourceCodeStart":551,"sourceCodeEnd":587,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSStripedInputStream.java#L551-L587","documentation":"DFSStripedInputStream deliberately does not implement enhanced (zero-copy) byte-buffer reads: read(ByteBufferPool, int, EnumSet<ReadOption>) unconditionally throws UnsupportedOperationException. Erasure-coded reads may need online read recovery — reconstructing missing cells from data plus parity — which cannot honor zero-copy semantics, so the capability is disabled for striped streams rather than returning wrong data.","triggerScenarios":"Calling FSDataInputStream.read(bufferPool, maxLength, opts) — the ByteBufferPool/zero-copy path used by high-throughput consumers such as HBase — on a stream opened from a file stored with an erasure-coding policy (e.g., RS-6-3-1024k).","commonSituations":"Migrating datasets or HBase-like workloads to EC policies and reusing zero-copy reader code that worked on replicated files; libraries that probe for enhanced byte-buffer support; enabling SKIP_CHECKSUMS/drop-behind options through the pooled-read API.","solutions":["Use the plain byte[] APIs (read(byte[], off, len), readFully) for erasure-coded files.","Branch up front: if the wrapped stream is a DFSStripedInputStream (or the file's EC policy is non-null), skip the ByteBufferPool path.","Catch UnsupportedOperationException at the call site and fall back to byte[] reads.","Upgrade the consuming library to a version with EC-aware read paths (e.g., newer HBase releases detect EC and avoid pooled reads)."],"exampleFix":"// before\nByteBuffer buf = in.read(bufferPool, maxLen,\n    EnumSet.of(ReadOption.SKIP_CHECKSUMS)); // throws on EC files\n\n// after\nif (in.getWrappedStream() instanceof DFSStripedInputStream) {\n  byte[] b = new byte[maxLen];\n  int n = in.read(b, 0, maxLen); // regular path, always supported\n} else {\n  ByteBuffer buf = in.read(bufferPool, maxLen,\n      EnumSet.of(ReadOption.SKIP_CHECKSUMS));\n}","handlingStrategy":"fallback","validationCode":"ErasureCodingPolicy ecPolicy =\n    fs.getClient().getErasureCodingPolicy(stat.getPath());\nif (ecPolicy != null) {\n  // erasure-coded: pooled zero-copy read is not offered; use byte[] read\n}\n// or check via file status replication == 0 marker for EC files\nif (stat.getReplication() == 0) { /* EC file: use read(byte[]) */ }","typeGuard":"boolean striped =\n    in.getWrappedStream() instanceof org.apache.hadoop.hdfs.DFSStripedInputStream;\nif (striped) {\n  // skip read(ByteBufferPool, ...) / releaseBuffer(...): they throw\n  // UnsupportedOperationException on erasure-coded files\n}","tryCatchPattern":"ByteBuffer buf = null;\ntry {\n  buf = in.read(bufferPool, maxLen, opts);\n} catch (UnsupportedOperationException e) {\n  // zero-copy unsupported (e.g., EC file) -> plain read path\n  byte[] b = new byte[maxLen];\n  int n = in.read(b, 0, maxLen);\n} finally {\n  if (buf != null) in.releaseBuffer(buf);\n}","preventionTips":["Before adopting zero-copy reads, check the file's storage policy: EC files never support read(ByteBufferPool, ...).","Wrap pooled-read usage so an UnsupportedOperationException silently degrades to byte[] reads.","When testing against EC datasets, add explicit cases for the pooled-read API so regressions surface early."],"tags":["hdfs","erasure-coding","zero-copy","bytebuffer","unsupported-operation","input-stream"],"backgroundTag":"unsupported-operation","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}