{"record":{"id":"6338ba79a38dceda","repo":"apache/hadoop","slug":"replica-of-type-does-not-support-createinfo","errorCode":null,"errorMessage":"Replica of type {} does not support createInfo","messagePattern":"Replica of type (.+?) does not support createInfo","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/ReplicaWaitingToBeRecovered.java","lineNumber":119,"sourceCode":"    throw new UnsupportedOperationException(\"Replica of type \" + getState() +\n        \" does not support getOriginalReplica\");\n  }\n\n  @Override\n  public long getRecoveryID() {\n    throw new UnsupportedOperationException(\"Replica of type \" + getState() +\n        \" does not support getRecoveryID\");\n  }\n\n  @Override\n  public void setRecoveryID(long recoveryId) {\n    throw new UnsupportedOperationException(\"Replica of type \" + getState() +\n        \" does not support getRecoveryID\");\n  }\n\n  @Override\n  public ReplicaRecoveryInfo createInfo() {\n    throw new UnsupportedOperationException(\"Replica of type \" + getState() +\n        \" does not support createInfo\");\n  }\n}\n","sourceCodeStart":101,"sourceCodeEnd":123,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/ReplicaWaitingToBeRecovered.java#L101-L123","documentation":"ReplicaWaitingToBeRecovered.createInfo() throws UnsupportedOperationException: createInfo() builds a ReplicaRecoveryInfo (state, id, generation stamp for the recovery handshake) and only replicas actively under recovery can produce one. An RWR replica must be promoted to RUR (wrapped in ReplicaUnderRecovery) before the recovery protocol can ask it for info.","triggerScenarios":"Calling createInfo() on a ReplicaWaitingToBeRecovered instance - e.g., during initBlockRecovery the code iterates replicas and calls createInfo() to build ReplicaRecoveryInfo for the NameNode, hitting an RWR entry without converting it first.","commonSituations":"Custom or test recovery flows that skip the ReplicaUnderRecovery wrapping step; downstream forks where block recovery was refactored and the RWR promotion was lost.","solutions":["Wrap the replica first: new ReplicaUnderRecovery(rwrReplica, recoveryId).createInfo()","Ensure initBlockRecovery() path is used - it performs the wrapping for you","Guard calls with a state check for ReplicaState.RUR before createInfo()"],"exampleFix":"// before\nReplicaRecoveryInfo info = replica.createInfo(); // throws for RWR\n\n// after\nReplicaRecoveryInfo info = (replica.getState() == ReplicaState.RUR)\n    ? replica.createInfo()\n    : new ReplicaUnderRecovery(replica, recoveryId).createInfo();","handlingStrategy":"type-guard","validationCode":"import org.apache.hadoop.hdfs.server.protocol.ReplicaState;\nif (replica.getState() != ReplicaState.RUR) {\n  replica = new ReplicaUnderRecovery(replica, recoveryId);\n}\nReplicaRecoveryInfo info = replica.createInfo();","typeGuard":"static boolean canCreateInfo(ReplicaInfo r) {\n  return r instanceof ReplicaUnderRecovery;\n}","tryCatchPattern":"try { info = r.createInfo(); } catch (UnsupportedOperationException e) { info = new ReplicaUnderRecovery(r, recoveryId).createInfo(); }","preventionTips":["Use DataNode.initBlockRecovery() rather than hand-rolling the wrap-then-createInfo sequence","Gate createInfo() calls on RUR state in any generic replica iteration"],"tags":["hdfs","datanode","block-recovery","replica","unsupported-operation"],"backgroundTag":"unsupported-operation","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}