apache/hadoop · error · UnsupportedOperationException
${className} stream does not support setting the drop-behind
Error message
${className} stream does not support setting the drop-behind caching setting. What it means
setDropBehind(Boolean) on CryptoInputStream is gated by an instanceof check, but the code tests `in instanceof CanSetReadahead` while casting to CanSetDropBehind — an interface mismatch. Net effect: a stream implementing drop-behind but not readahead gets UnsupportedOperationException here, and a stream implementing readahead but not drop-behind passes the gate and fails with ClassCastException at the cast.
Source
Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/CryptoInputStream.java:761
}
((HasEnhancedByteBufferAccess) in).releaseBuffer(buffer);
}
@Override
public void setReadahead(Long readahead) throws IOException,
UnsupportedOperationException {
if (!(in instanceof CanSetReadahead)) {
throw new UnsupportedOperationException(in.getClass().getCanonicalName()
+ " does not support setting the readahead caching strategy.");
}
((CanSetReadahead) in).setReadahead(readahead);
}
@Override
public void setDropBehind(Boolean dropCache) throws IOException,
UnsupportedOperationException {
if (!(in instanceof CanSetReadahead)) {
throw new UnsupportedOperationException(in.getClass().getCanonicalName()
+ " stream does not support setting the drop-behind caching"
+ " setting.");
}
((CanSetDropBehind) in).setDropBehind(dropCache);
}
@Override
public FileDescriptor getFileDescriptor() throws IOException {
if (in instanceof HasFileDescriptor) {
return ((HasFileDescriptor) in).getFileDescriptor();
} else if (in instanceof FileInputStream) {
return ((FileInputStream) in).getFD();
} else {
return null;
}
}
@OverrideView on GitHub (pinned to 2add963021)
Solutions
- Make drop-behind tuning best-effort: catch both UnsupportedOperationException and ClassCastException on affected versions
- Implement both CanSetReadahead and CanSetDropBehind on custom wrapped streams
- Upgrade or patch Hadoop — the gate should test CanSetDropBehind; track the upstream fix if vendor branching
Example fix
// before
fsIn.setDropBehind(true); // UOE (or ClassCastException) due to wrong-interface gate
// after
try {
fsIn.setDropBehind(true);
} catch (UnsupportedOperationException | ClassCastException e) {
LOG.debug("Drop-behind tuning not supported for this stream");
} Defensive patterns
Strategy: try-catch
Try / catch
try {
fsIn.setDropBehind(dropBehind);
} catch (UnsupportedOperationException | ClassCastException e) {
// gate checks CanSetReadahead but casts CanSetDropBehind on affected versions
LOG.debug("Drop-behind tuning unsupported on this stream");
} Prevention
- Catch both UnsupportedOperationException and ClassCastException around setDropBehind on this code path
- Implement both CanSetReadahead and CanSetDropBehind on custom wrapped streams
- Track the upstream fix (instanceof should test CanSetDropBehind) and patch vendor branches
When it happens
Trigger: Calling setDropBehind() on a CryptoInputStream whose inner stream does not implement CanSetReadahead (wrong-interface gate); conversely, a custom stream implementing CanSetReadahead but not CanSetDropBehind fails at the cast line below the check.
Common situations: Page-cache/drop-behind tuning applied to encrypted reads; custom wrapped streams implementing only one of the two capability interfaces; code that worked against plain HDFS streams failing once encryption is enabled.
Related errors
- ${className} does not support setting the readahead caching
- ${className} does not support positioned read.
- ${className} does not support positioned reads with byte buf
- ${className} does not support positioned readFully.
- Cannot seek to a negative offset
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/0fc3ff6b80553089.
Report an issue: GitHub.