apache/hadoop · error · UnsupportedOperationException
Replica of type {} does not support getOriginalReplica
Error message
Replica of type {} does not support getOriginalReplica What it means
ReplicaWaitingToBeRecovered (state RWR) deliberately does not support the recovery-info API surface: getOriginalReplica() throws UnsupportedOperationException because an RWR replica is not a wrapper around some other replica. Recovery metadata only exists on ReplicaUnderRecovery. This is a programming error, not an environmental condition.
Source
Thrown at hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/ReplicaWaitingToBeRecovered.java:101
@Override // Object
public boolean equals(Object o) {
return super.equals(o);
}
@Override // Object
public int hashCode() {
return super.hashCode();
}
@Override
public String toString() {
return super.toString();
}
@Override
public ReplicaInfo getOriginalReplica() {
throw new UnsupportedOperationException("Replica of type " + getState() +
" does not support getOriginalReplica");
}
@Override
public long getRecoveryID() {
throw new UnsupportedOperationException("Replica of type " + getState() +
" does not support getRecoveryID");
}
@Override
public void setRecoveryID(long recoveryId) {
throw new UnsupportedOperationException("Replica of type " + getState() +
" does not support getRecoveryID");
}
@Override
public ReplicaRecoveryInfo createInfo() {
throw new UnsupportedOperationException("Replica of type " + getState() +View on GitHub (pinned to 2add963021)
Solutions
- Guard with instanceof ReplicaUnderRecovery before calling getOriginalReplica()
- Or gate on state: only ReplicaState.RUR exposes recovery info; skip FINALIZED/RBW/RWR/TEMPORARY
- Re-check your recovery flow: RWR replicas become recoverable via ReplicaUnderRecovery wrapping, not directly
Example fix
// before
ReplicaInfo original = r.getOriginalReplica(); // throws for RWR
// after
ReplicaInfo original = (r instanceof ReplicaUnderRecovery)
? ((ReplicaUnderRecovery) r).getOriginalReplica()
: r; Defensive patterns
Strategy: type-guard
Validate before calling
if (!(r instanceof ReplicaUnderRecovery)) { /* RWR and others: use r itself */ } Type guard
static boolean hasOriginalReplica(ReplicaInfo r) {
return r instanceof ReplicaUnderRecovery;
}
// ReplicaInfo original = hasOriginalReplica(r) ? ((ReplicaUnderRecovery) r).getOriginalReplica() : r; Try / catch
try { r.getOriginalReplica(); } catch (UnsupportedOperationException e) { /* not under recovery: fall back to treating r as the original */ } Prevention
- Never call recovery-info APIs without an instanceof ReplicaUnderRecovery check
- Remember the state model: RUR wraps an original; RWR/RBW/FINALIZED/TEMPORARY do not
When it happens
Trigger: Calling getOriginalReplica() on any ReplicaInfo whose runtime type is ReplicaWaitingToBeRecovered - e.g., generic recovery code that assumes every non-finalized replica is under recovery and calls getOriginalReplica() without an instanceof check.
Common situations: Custom FsDataset implementations or tests that iterate the volume map during recovery and call the recovery API uniformly on all replicas; misclassifying RWR (replica waiting to be recovered because its datanode was down) as RUR (replica under recovery).
Related errors
- Replica of type {} does not support getRecoveryID
- Replica of type {} does not support createInfo
- Replica of type ${getState()} does not support getOriginalRe
- Replica of type ${getState()} does not support getOriginalRe
- Replica of type ${getState()} does not support getRecoveryID
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/590cfcc557b360e6.
Report an issue: GitHub.