apache/hadoop · error · UnsupportedOperationException
{} doesn't support unsetStoragePolicy
Error message
{} doesn't support unsetStoragePolicy What it means
AbstractFileSystem.unsetStoragePolicy(Path) is a default stub that throws UnsupportedOperationException naming the subclass. Unsetting (reverting to inherited/default policy) is HDFS-only; filesystems without a storage-policy engine keep the stub. The error indicates scheme-level non-support, not a missing or already-unset policy.
Source
Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/AbstractFileSystem.java:1547
* @param policyName the name of the target storage policy. The list
* of supported Storage policies can be retrieved
* via {@link #getAllStoragePolicies}.
* @throws IOException raised on errors performing I/O.
*/
public void setStoragePolicy(final Path path, final String policyName)
throws IOException {
throw new UnsupportedOperationException(getClass().getSimpleName()
+ " doesn't support setStoragePolicy");
}
/**
* Unset the storage policy set for a given file or directory.
* @param src file or directory path.
* @throws IOException raised on errors performing I/O.
*/
public void unsetStoragePolicy(final Path src) throws IOException {
throw new UnsupportedOperationException(getClass().getSimpleName()
+ " doesn't support unsetStoragePolicy");
}
/**
* Retrieve the storage policy for a given file or directory.
*
* @param src file or directory path.
* @return storage policy for give file.
* @throws IOException raised on errors performing I/O.
*/
public BlockStoragePolicySpi getStoragePolicy(final Path src)
throws IOException {
throw new UnsupportedOperationException(getClass().getSimpleName()
+ " doesn't support getStoragePolicy");
}
/**
* Retrieve all the storage policies supported by this file system.View on GitHub (pinned to 2add963021)
Solutions
- Restrict unsetStoragePolicy calls to hdfs:// paths.
- Use DistributedFileSystem.unsetStoragePolicy / `hdfs dfsadmin -unsetStoragePolicy` for the supported path.
- Gate by URI scheme in shared code.
- Catch UnsupportedOperationException and skip when the store has no policy concept.
Example fix
// before
fc.unsetStoragePolicy(path); // throws on unsupported scheme
// after
if ("hdfs".equals(path.toUri().getScheme())) {
fc.unsetStoragePolicy(path);
} Defensive patterns
Strategy: validation
Validate before calling
static boolean policyOpsSupported(Path p) {
return "hdfs".equals(p.toUri().getScheme());
} Try / catch
try {
fc.unsetStoragePolicy(path);
} catch (UnsupportedOperationException e) {
// nothing to unset: store has no policies
} Prevention
- Only unset policies on paths where a set previously succeeded
- Track policy state per scheme in your management tooling
When it happens
Trigger: FileContext.unsetStoragePolicy(src) against non-HDFS schemes; policy-management code that unsets policies during directory reorganization run on local or object-store paths.
Common situations: Policy lifecycle scripts (set on ingest, unset on archive) run against the wrong cluster/endpoint; test environments with file:// defaultFS; viewfs mounts to non-HDFS targets.
Related errors
- {} doesn't support satisfyStoragePolicy
- {} doesn't support setStoragePolicy
- {} doesn't support getStoragePolicy
- {} doesn't support getAllStoragePolicies
- {} does not support listCorruptFileBlocks
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/bb193d662a6ee3d5.
Report an issue: GitHub.