{"record":{"id":"ca498088ca2daf12","repo":"apache/hadoop","slug":"block-inputstream-has-no-filechannel-ca4980","errorCode":null,"errorMessage":"Block InputStream has no FileChannel.","messagePattern":"Block InputStream has no FileChannel\\.","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/PmemMappableBlockLoader.java","lineNumber":93,"sourceCode":"   * @param key            The extended block ID.\n   *\n   * @throws IOException   If mapping block fails or checksum fails.\n   *\n   * @return               The Mappable block.\n   */\n  @Override\n  MappableBlock load(long length, FileInputStream blockIn,\n      FileInputStream metaIn, String blockFileName, ExtendedBlockId key)\n      throws IOException {\n    PmemMappedBlock mappableBlock = null;\n    String cachePath = null;\n\n    FileChannel blockChannel = null;\n    RandomAccessFile cacheFile = null;\n    try {\n      blockChannel = blockIn.getChannel();\n      if (blockChannel == null) {\n        throw new IOException(\"Block InputStream has no FileChannel.\");\n      }\n      cachePath = pmemVolumeManager.getCachePath(key);\n      cacheFile = new RandomAccessFile(cachePath, \"rw\");\n      blockChannel.transferTo(0, length, cacheFile.getChannel());\n\n      // Verify checksum for the cached data instead of block file.\n      // The file channel should be repositioned.\n      cacheFile.getChannel().position(0);\n      verifyChecksum(length, metaIn, cacheFile.getChannel(), blockFileName);\n\n      mappableBlock = new PmemMappedBlock(length, key);\n      LOG.info(\"Successfully cached one replica:{} into persistent memory\"\n          + \", [cached path={}, length={}]\", key, cachePath, length);\n    } finally {\n      IOUtils.closeStream(blockChannel);\n      IOUtils.closeStream(cacheFile);\n      if (mappableBlock == null) {\n        LOG.debug(\"Delete {} due to unsuccessful mapping.\", cachePath);","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/PmemMappableBlockLoader.java#L75-L111","documentation":"Thrown by PmemMappableBlockLoader.load() (PmemMappableBlockLoader.java:93) - the pure-Java pmem cache loader that copies the block file into the pmem volume via RandomAccessFile/transferTo - when blockIn.getChannel() returns null. As with the other loaders, FileInputStream.getChannel() on a stock JDK never returns null, so this is a defensive guard that normal workloads cannot reach; realistic failures on this path are pmem volume misconfiguration or I/O errors during the copy.","triggerScenarios":"Only a non-standard JVM/instrumented stream could trip it; HDFS always passes a FileInputStream opened on the block file.","commonSituations":"Does not occur in practice; if reported, look at JDK-level tampering rather than dfs.datanode.pmem.cache.dirs or cache directives.","solutions":["Retest on a stock supported JDK with agents removed","If reproducible, include the stream's concrete class in the exception via a debug patch and file a JIRA","The single caching attempt fails cleanly and is retried by FsDatasetCache later; no manual uncache is needed"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  MappableBlock blk = pmemLoader.load(\n      length, blockIn, metaIn, blockFileName, key);\n} catch (IOException e) {\n  // loader's finally closes the partial cache file; report and let the directive retry\n  LOG.warn(\"pmem (java) caching failed for {}: {}\", key, e);\n}","preventionTips":["Stock JDK only; the null-channel branch cannot trip for FileInputStream.getChannel()","Validate dfs.datanode.pmem.cache.dirs health instead - that is where this loader really fails"],"tags":["hdfs","datanode","pmem","centralized-cache","filechannel","defensive-check"],"backgroundTag":"file-channel-unavailable","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}