{"record":{"id":"08490c21e51a0f64","repo":"apache/hadoop","slug":"doesn-t-support-setstoragepolicy","errorCode":null,"errorMessage":"{} doesn't support setStoragePolicy","messagePattern":"(.+?) doesn't support setStoragePolicy","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/AbstractFileSystem.java","lineNumber":1536,"sourceCode":"   * @throws IOException raised on errors performing I/O.\n   */\n  public void satisfyStoragePolicy(final Path path) throws IOException {\n    throw new UnsupportedOperationException(\n        getClass().getSimpleName() + \" doesn't support satisfyStoragePolicy\");\n  }\n\n  /**\n   * Set the storage policy for a given file or directory.\n   *\n   * @param path file or directory path.\n   * @param policyName the name of the target storage policy. The list\n   *                   of supported Storage policies can be retrieved\n   *                   via {@link #getAllStoragePolicies}.\n   * @throws IOException raised on errors performing I/O.\n   */\n  public void setStoragePolicy(final Path path, final String policyName)\n      throws IOException {\n    throw new UnsupportedOperationException(getClass().getSimpleName()\n        + \" doesn't support setStoragePolicy\");\n  }\n\n\n  /**\n   * Unset the storage policy set for a given file or directory.\n   * @param src file or directory path.\n   * @throws IOException raised on errors performing I/O.\n   */\n  public void unsetStoragePolicy(final Path src) throws IOException {\n    throw new UnsupportedOperationException(getClass().getSimpleName()\n        + \" doesn't support unsetStoragePolicy\");\n  }\n\n  /**\n   * Retrieve the storage policy for a given file or directory.\n   *\n   * @param src file or directory path.","sourceCodeStart":1518,"sourceCodeEnd":1554,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/AbstractFileSystem.java#L1518-L1554","documentation":"AbstractFileSystem.setStoragePolicy(Path, String) is a default stub throwing UnsupportedOperationException with the implementing class name. Block storage policies (HOT/WARM/COLD, EC policies' storage types) are an HDFS concept; the FileContext path hits the stub whenever the resolved implementation does not override it.","triggerScenarios":"FileContext.setStoragePolicy(path, \"COLD\") on file://, s3a://, gs://, or ftp:// URIs; policy-assignment code run in local unit tests; a viewfs path whose target store is not HDFS.","commonSituations":"Tiering/ILM code written against HDFS gets exercised against local FS in tests or against object stores after migration; the policy name is valid but the store simply has no policy engine.","solutions":["Apply storage policies only on hdfs:// paths; validate the scheme before calling.","Use DistributedFileSystem.setStoragePolicy or `hdfs dfsadmin -setStoragePolicy` for the supported flow.","Check the policy name against getAllStoragePolicies() where supported instead of assuming.","Catch UnsupportedOperationException and skip policy assignment on stores without support."],"exampleFix":"// before\nfc.setStoragePolicy(path, \"COLD\"); // throws: LocalFs doesn't support setStoragePolicy\n\n// after\nif (\"hdfs\".equals(path.toUri().getScheme())) {\n  fc.setStoragePolicy(path, \"COLD\");\n}","handlingStrategy":"validation","validationCode":"static boolean policyOpsSupported(Path p) {\n  return \"hdfs\".equals(p.toUri().getScheme());\n}","typeGuard":null,"tryCatchPattern":"try {\n  fc.setStoragePolicy(path, \"COLD\");\n} catch (UnsupportedOperationException e) {\n  // no policy engine on this filesystem: skip assignment\n}","preventionTips":["Validate the policy name against getAllStoragePolicies() on supported filesystems","Keep tiering configuration scoped per scheme"],"tags":["hadoop","filesystem","storage-policy","hdfs","unsupportedoperationexception"],"backgroundTag":"storage-policy-unsupported","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}