{"record":{"id":"5c7941fd40c03134","repo":"apache/hadoop","slug":"refresh-not-supported-by-getclass","errorCode":null,"errorMessage":"Refresh not supported by \" + getClass()","messagePattern":"Refresh not supported by \" \\+ getClass\\(\\)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"warning","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/common/blockaliasmap/impl/TextFileRegionAliasMap.java","lineNumber":469,"sourceCode":"      out.append(Long.toString(psl.getLength())).append(delim);\n      out.append(Long.toString(block.getGenerationStamp()));\n      if (psl.getNonce().length > 0) {\n        out.append(delim)\n            .append(Base64.getEncoder().encodeToString(psl.getNonce()));\n      }\n      out.append(\"\\n\");\n    }\n\n    @Override\n    public void close() throws IOException {\n      out.close();\n    }\n\n  }\n\n  @Override\n  public void refresh() throws IOException {\n    throw new UnsupportedOperationException(\n        \"Refresh not supported by \" + getClass());\n  }\n\n  @Override\n  public void close() throws IOException {\n    // nothing to do;\n  }\n\n  @VisibleForTesting\n  public static String blockPoolIDFromFileName(Path file) {\n    if (file == null) {\n      return \"\";\n    }\n    String fileName = file.getName();\n    return fileName.substring(\"blocks_\".length()).split(\"\\\\.\")[0];\n  }\n\n  @VisibleForTesting","sourceCodeStart":451,"sourceCodeEnd":487,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/common/blockaliasmap/impl/TextFileRegionAliasMap.java#L451-L487","documentation":"BlockAliasMap.refresh() is the extension point for implementations that can reload their backing state without restarting. TextFileRegionAliasMap does not support it and always throws UnsupportedOperationException — its TextReader opens the text file on demand, so there is no cached state to refresh.","triggerScenarios":"Invoking refresh() on a TextFileRegionAliasMap instance, typically through generic management/tooling code that calls refresh on whatever alias map dfs.provided.aliasmap.class selected.","commonSituations":"Switching the alias map implementation to text while retaining a refresh call; ops tooling that 'refreshes all alias maps' after regenerating the text file.","solutions":["Drop or skip the refresh() call when the implementation is the text alias map","To pick up a regenerated file, simply obtain a new Reader via getReader() — each reader re-opens the file","If runtime refresh is a hard requirement, use an implementation that supports it (e.g., InMemoryLevelDBAliasMap) instead of text"],"exampleFix":"// before\naliasMap.refresh(); // throws for TextFileRegionAliasMap\n\n// after\nif (aliasMap instanceof TextFileRegionAliasMap) {\n  reader = aliasMap.getReader(null, bpid); // fresh reader re-opens the file\n} else {\n  aliasMap.refresh();\n}","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"static boolean supportsRefresh(BlockAliasMap<?> map) {\n  return !(map instanceof TextFileRegionAliasMap);\n}","tryCatchPattern":null,"preventionTips":["Check the alias map implementation before calling optional operations like refresh()","Prefer re-acquiring a Reader over refreshing when the implementation is file-backed"],"tags":["provided-storage","aliasmap","text","unsupported-operation","refresh"],"backgroundTag":"unsupported-operation","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}