{"record":{"id":"088b9269cf82e16e","repo":"apache/hadoop","slug":"cannot-clone-stream-belongs-to-a-different-dfscli","errorCode":null,"errorMessage":"Cannot clone: stream belongs to a different DFSClient instance","messagePattern":"Cannot clone: stream belongs to a different DFSClient instance","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java","lineNumber":456,"sourceCode":"   * @throws IOException if the stream cannot be cloned\n   */\n  public FSDataInputStream cloneDataInputStream(FSDataInputStream existing)\n      throws IOException {\n    statistics.incrementReadOps(1);\n    storageStatistics.incrementOpCounter(OpType.OPEN);\n    InputStream wrapped = existing.getWrappedStream();\n    DFSInputStream dfsis;\n    if (wrapped instanceof DFSInputStream dfsIn) {\n      dfsis = dfsIn;\n    } else if (wrapped instanceof\n        org.apache.hadoop.crypto.CryptoInputStream cryptoIn) {\n      dfsis = (DFSInputStream) cryptoIn.getWrappedStream();\n    } else {\n      throw new IOException(\"Cannot clone: underlying stream is \"\n          + wrapped.getClass().getName() + \", not a DFSInputStream\");\n    }\n    if (dfsis.getDFSClient() != dfs) {\n      throw new IOException(\n          \"Cannot clone: stream belongs to a different DFSClient instance\");\n    }\n    LocatedBlocks locatedBlocks = dfsis.getLocatedBlocks();\n    String src = dfsis.getSrc();\n    DFSInputStream clone = dfs.open(src,\n        dfs.getConf().getIoBufferSize(), verifyChecksum, locatedBlocks);\n    try {\n      return dfs.createWrappedInputStream(clone);\n    } catch (IOException e) {\n      clone.close();\n      throw e;\n    }\n  }\n\n  @Override\n  public String getErasureCodingPolicyName(FileStatus fileStatus) {\n    if (!(fileStatus instanceof HdfsFileStatus)) {\n      return null;","sourceCodeStart":438,"sourceCodeEnd":474,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java#L438-L474","documentation":"Error \"Cannot clone: stream belongs to a different DFSClient instance\" thrown in apache/hadoop.","triggerScenarios":"An open-stream clone is requested for a stream that was created by a different DFSClient instance; clones must share the same client.","commonSituations":"See trigger scenarios.","solutions":["Clone the stream using the same DFSClient/FileSystem instance that opened it.","Reopen the file with the current FileSystem instead of cloning a stream from another client."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}