{"record":{"id":"ee8628dac4ac35da","repo":"apache/hadoop","slug":"not-able-to-initialize-fs-in-getdefaultreplicatio","errorCode":null,"errorMessage":"Not able to initialize fs in  getDefaultReplication for path <f> with exception","messagePattern":"Not able to initialize fs in  getDefaultReplication for path <f> with exception","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java","lineNumber":989,"sourceCode":"      return res.targetFileSystem.getDefaultBlockSize(res.remainingPath);\n    } catch (FileNotFoundException e) {\n      throw new NotInMountpointException(f, \"getDefaultBlockSize\");\n    } catch (IOException e) {\n      throw new RuntimeException(\"Not able to initialize fs in \"\n          + \" getDefaultBlockSize for path \" + f + \" with exception\", e);\n    }\n  }\n\n  @Override\n  public short getDefaultReplication(Path f) {\n    try {\n      InodeTree.ResolveResult<FileSystem> res =\n        fsState.resolve(getUriPath(f), true);\n      return res.targetFileSystem.getDefaultReplication(res.remainingPath);\n    } catch (FileNotFoundException e) {\n      throw new NotInMountpointException(f, \"getDefaultReplication\");\n    } catch (IOException e) {\n      throw new RuntimeException(\"Not able to initialize fs in \"\n          + \" getDefaultReplication for path \" + f + \" with exception\", e);\n    }\n  }\n\n  @Override\n  public FsServerDefaults getServerDefaults(Path f) throws IOException {\n    try {\n      InodeTree.ResolveResult<FileSystem> res =\n          fsState.resolve(getUriPath(f), true);\n      return res.targetFileSystem.getServerDefaults(res.remainingPath);\n    } catch (FileNotFoundException e) {\n      throw new NotInMountpointException(f, \"getServerDefaults\");\n    }\n  }\n\n  @Override\n  public ContentSummary getContentSummary(Path f) throws IOException {\n    InodeTree.ResolveResult<FileSystem> res =","sourceCodeStart":971,"sourceCodeEnd":1007,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java#L971-L1007","documentation":"In ViewFileSystem.getDefaultReplication(Path), resolving the path requires initializing the target FileSystem of its mount point. An IOException raised during that initialization (name node unreachable, bad HA config, security failure) is wrapped in an unchecked RuntimeException whose message names the operation and path; the real IOException is the cause.","triggerScenarios":"getDefaultReplication(path) on a path whose mount entry targets an HDFS that is down, a nameservice not defined in the client's hdfs-site.xml, a wrong port/authority in fs.viewfs.mounttable.default.link.*, or a Kerberos/TLS failure while creating the proxy FileSystem.","commonSituations":"Federated clusters where one sub-cluster is unavailable; clients that copied core-site.xml (mount table) but not the matching hdfs-site.xml; DR failovers where the mount table still references the dead cluster.","solutions":["Unwrap and inspect the cause IOException to identify the failing authority","Probe each mount target directly: `hadoop fs -ls hdfs://<authority-from-mount-table>/`","Correct the mount entry or provide the missing HA/failover configuration on the client","Guard generic code: catch RuntimeException, check for IOException cause, and degrade gracefully (report target cluster outage)"],"exampleFix":"// before\nshort rep = fs.getDefaultReplication(outDir); // RuntimeException with buried cause\n\n// after\nshort rep;\ntry {\n  rep = fs.getDefaultReplication(outDir);\n} catch (RuntimeException e) {\n  if (e.getCause() instanceof IOException) {\n    throw new IOException(\"Target FS of \" + outDir + \" down: \" + e.getCause().getMessage(), e.getCause());\n  }\n  throw e;\n}","handlingStrategy":"retry","validationCode":"// Pre-flight: initialize each target FileSystem in the mount table once\nstatic void preflightMounts(Configuration conf) throws IOException {\n  for (Map.Entry<String,String> e : conf) {\n    if (e.getKey().startsWith(\"fs.viewfs.mounttable.\")) {\n      FileSystem.get(new URI(e.getValue()), conf).exists(new Path(\"/\"));\n    }\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  short rep = fs.getDefaultReplication(p);\n} catch (RuntimeException e) {\n  Throwable c = e.getCause();\n  if (c instanceof IOException) {\n    // target FS down: retry with backoff or fail over per HA config\n    throw new IOException(\"viewfs target for \" + p + \" unreachable\", c);\n  }\n  throw e;\n}","preventionTips":["Run mount-table preflight checks at application startup","Keep HA failover configs correct and identical on all clients","Monitor name nodes referenced by the mount table; a dead sub-cluster breaks viewfs clients that touch it"],"tags":["viewfs","hadoop","hdfs","ha","connection","runtimeexception"],"backgroundTag":"target-filesystem-unreachable","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}