{"record":{"id":"56276351f8ff71c0","repo":"apache/hadoop","slug":"replica-of-type-getstate-does-not-support-get-562763","errorCode":null,"errorMessage":"Replica of type ${getState()} does not support getRecoveryID","messagePattern":"Replica of type (.+?) does not support getRecoveryID","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/FinalizedProvidedReplica.java","lineNumber":107,"sourceCode":"  @Override  // Object\n  public int hashCode() {\n    return super.hashCode();\n  }\n\n  @Override\n  public String toString() {\n    return super.toString();\n  }\n\n  @Override\n  public ReplicaInfo getOriginalReplica() {\n    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","sourceCodeStart":89,"sourceCodeEnd":123,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/FinalizedProvidedReplica.java#L89-L123","documentation":"Recovery IDs exist only for replicas under recovery (RBW/RWR/RUR track a recoveryId through truncate/commit flows). FinalizedProvidedReplica is a FINALIZED replica backed by external PROVIDED storage and carries no recovery ID, so getRecoveryID() throws UnsupportedOperationException.","triggerScenarios":"Block-recovery code calling getRecoveryID() on a replica that turns out to be a FinalizedProvidedReplica — e.g., recovery initiated for a block whose only local copy is PROVIDED, or generic code enumerating volume-map replicas and reading recovery IDs unconditionally.","commonSituations":"PROVIDED-storage clusters where recovery flows encounter provided replicas; monitoring or tooling code that assumes every replica supports the full ReplicaInfo API; version upgrades adding recovery call sites that lack provided-storage guards.","solutions":["Narrow the call site: only read recovery IDs from replicas in RBW/RWR/RUR states (instanceof ReplicaUnderReconstruction or state checks).","Do not include provided replicas in recovery handshakes; pick a local replica on another DataNode.","Upgrade to a Hadoop version with provided-storage guards in the affected flow, and check the JIRA for your code path.","In custom datasets, return a recovery-capable view only for replicas that actually track recovery."],"exampleFix":"// before\nlong recoveryId = replica.getRecoveryID();\n\n// after: state-check before reading recovery bookkeeping\nif (replica.getState() == ReplicaState.RUR\n    || replica.getState() == ReplicaState.RBW\n    || replica.getState() == ReplicaState.RWR) {\n  long recoveryId = replica.getRecoveryID();\n} else {\n  // FINALIZED / PROVIDED: no recovery ID exists\n}","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"static boolean hasRecoveryId(ReplicaInfo r) {\n  ReplicaState s = r.getState();\n  return s == ReplicaState.RBW || s == ReplicaState.RWR || s == ReplicaState.RUR;\n}","tryCatchPattern":"try {\n  long id = replica.getRecoveryID();\n} catch (UnsupportedOperationException e) {\n  // replica carries no recovery ID (FINALIZED/PROVIDED): pick another recovery candidate\n}","preventionTips":["Read recovery IDs only from recovery-state replicas (RBW/RWR/RUR)","Keep monitoring code from assuming ReplicaInfo's full API is implemented by every replica class","Track provided-storage JIRAs when upgrading clusters that use PROVIDED storage"],"tags":["provided-storage","replica","recovery","unsupported-operation","hdfs"],"backgroundTag":"unsupported-operation","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}