{"record":{"id":"dbc8da7e78ecb435","repo":"apache/hadoop","slug":"replica-of-type-getstate-does-not-support-cre-dbc8da","errorCode":null,"errorMessage":"Replica of type ${getState()} 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/FinalizedReplica.java","lineNumber":144,"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 setRecoveryID\");\n  }\n\n  @Override\n  public ReplicaRecoveryInfo createInfo() {\n    throw new UnsupportedOperationException(\"Replica of type \" + getState() +\n        \" does not support createInfo\");\n  }\n\n  @Override\n  public long getMetadataLength() {\n    if (metaLength < 0) {\n      metaLength = (int)super.getMetadataLength();\n    }\n    return metaLength;\n  }\n\n  public byte[] getLastPartialChunkChecksum() {\n    return lastPartialChunkChecksum;\n  }\n\n  public void setLastPartialChunkChecksum(byte[] checksum) {\n    lastPartialChunkChecksum = checksum;\n  }","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/FinalizedReplica.java#L126-L162","documentation":"createInfo() produces the ReplicaRecoveryInfo for the recovery handshake and is only implemented for replica states that participate in recovery. A FINALIZED FinalizedReplica throws UnsupportedOperationException, so any recovery flow that calls createInfo() on it has a missing state check. (Note: FinalizedReplica itself does not override createInfo here — the base behavior rejects it.)","triggerScenarios":"Block recovery calling createInfo() on a replica with state FINALIZED instead of the under-reconstruction copy; generic code building recovery info from every replica in a volume-map scan.","commonSituations":"Custom recovery implementations; refactored framework flows that lost a type filter; integration tests that stub volume maps with finalized replicas.","solutions":["Select the recovery participant replica (RUR/RBW/RWR) before building ReplicaRecoveryInfo.","Fix the caller to skip or specially handle FINALIZED replicas instead of letting UnsupportedOperationException escape.","Add tests that drive recovery with finalized replicas present.","Check the Hadoop version for known fixes if this originates in framework code."],"exampleFix":"// before\nReplicaRecoveryInfo info = replica.createInfo();\n\n// after\nif (replica instanceof ReplicaUnderReconstruction) {\n  ReplicaRecoveryInfo info = replica.createInfo();\n} else {\n  // finalized replica: exclude from recovery handshake\n}","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"static boolean canBuildRecoveryInfo(ReplicaInfo r) {\n  return r instanceof ReplicaUnderReconstruction;\n}","tryCatchPattern":"try {\n  ReplicaRecoveryInfo info = replica.createInfo();\n} catch (UnsupportedOperationException e) {\n  // FINALIZED replica cannot join the recovery handshake: exclude it and fix the caller\n}","preventionTips":["Build recovery info only from recovery participants","Verify the Hadoop version's recovery code handles finalized replicas before upgrading custom forks","Treat these exceptions as state-machine bugs; add the missing state filter at the call site"],"tags":["replica","finalized","recovery","unsupported-operation","hdfs","datanode"],"backgroundTag":"unsupported-operation","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}