apache/hadoop · error · UnsupportedOperationException
{} doesn't support getAllStoragePolicies
Error message
{} doesn't support getAllStoragePolicies What it means
AbstractFileSystem.getAllStoragePolicies() is a default stub that throws UnsupportedOperationException naming the subclass. Enumerating the storage-policy catalog is HDFS-only; through FileContext any other resolved implementation fails with this error before returning a collection.
Source
Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/AbstractFileSystem.java:1572
* @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.
*
* @return all storage policies supported by this filesystem.
* @throws IOException raised on errors performing I/O.
*/
public Collection<? extends BlockStoragePolicySpi> getAllStoragePolicies()
throws IOException {
throw new UnsupportedOperationException(getClass().getSimpleName()
+ " doesn't support getAllStoragePolicies");
}
@Override //Object
public int hashCode() {
return myUri.hashCode();
}
@Override //Object
public boolean equals(Object other) {
if (!(other instanceof AbstractFileSystem)) {
return false;
}
return myUri.equals(((AbstractFileSystem) other).myUri);
}
/**
* Open a file with the given set of options.View on GitHub (pinned to 2add963021)
Solutions
- Call getAllStoragePolicies only on hdfs:// filesystems.
- Use DistributedFileSystem.getAllStoragePolicies or `hdfs dfsadmin -listStoragePolicies`.
- Probe once at startup, catch UnsupportedOperationException, and cache "policies unavailable" for that filesystem.
- Default to an empty policy list in UIs when the backend has no policy engine.
Example fix
// before
Collection<? extends BlockStoragePolicySpi> ps = fc.getAllStoragePolicies();
// after
Collection<? extends BlockStoragePolicySpi> ps;
try {
ps = fc.getAllStoragePolicies();
} catch (UnsupportedOperationException e) {
ps = Collections.emptyList();
} Defensive patterns
Strategy: try-catch
Validate before calling
static boolean policyOpsSupported(Path p) {
return "hdfs".equals(p.toUri().getScheme());
} Try / catch
try {
policies = fc.getAllStoragePolicies();
} catch (UnsupportedOperationException e) {
policies = Collections.emptyList();
} Prevention
- Enumerate policies once per filesystem connection, not per path
- Default UIs/config tools to an empty policy list when the probe throws
When it happens
Trigger: FileContext.getAllStoragePolicies() on local or object-store filesystems; tools that populate a policy dropdown/list from the filesystem (like `hdfs dfsadmin -listStoragePolicies` but via the generic API) pointed at a non-HDFS defaultFS.
Common situations: Cluster-management or UI code enumerating policies on connect, executed in tests with file://; a client configured for the wrong endpoint (s3a endpoint URL) where the code assumed HDFS.
Related errors
- {} doesn't support satisfyStoragePolicy
- {} doesn't support setStoragePolicy
- {} doesn't support unsetStoragePolicy
- {} doesn't support getStoragePolicy
- {} does not support listCorruptFileBlocks
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/230ef959752549e1.
Report an issue: GitHub.