{"record":{"id":"3781177eb74efba3","repo":"apache/hadoop","slug":"not-implemented-by-the-getclass-getsimplename","errorCode":null,"errorMessage":"Not implemented by the ${getClass().getSimpleName()} FileSystem implementation","messagePattern":"Not implemented by the (.+?) FileSystem implementation","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java","lineNumber":362,"sourceCode":"      scheme = name.getScheme();\n    }\n    statistics = getStatistics(scheme, getClass());\n    resolveSymlinks = conf.getBoolean(\n        CommonConfigurationKeysPublic.FS_CLIENT_RESOLVE_REMOTE_SYMLINKS_KEY,\n        CommonConfigurationKeysPublic.FS_CLIENT_RESOLVE_REMOTE_SYMLINKS_DEFAULT);\n  }\n\n  /**\n   * Return the protocol scheme for this FileSystem.\n   * <p>\n   * This implementation throws an <code>UnsupportedOperationException</code>.\n   *\n   * @return the protocol scheme for this FileSystem.\n   * @throws UnsupportedOperationException if the operation is unsupported\n   *         (default).\n   */\n  public String getScheme() {\n    throw new UnsupportedOperationException(\"Not implemented by the \"\n        + getClass().getSimpleName() + \" FileSystem implementation\");\n  }\n\n  /**\n   * Returns a URI which identifies this FileSystem.\n   *\n   * @return the URI of this filesystem.\n   */\n  public abstract URI getUri();\n\n  /**\n   * Return a canonicalized form of this FileSystem's URI.\n   *\n   * The default implementation simply calls {@link #canonicalizeUri(URI)}\n   * on the filesystem's own URI, so subclasses typically only need to\n   * implement that method.\n   *\n   * @see #canonicalizeUri(URI)","sourceCodeStart":344,"sourceCodeEnd":380,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java#L344-L380","documentation":"FileSystem.getScheme() is an optional override introduced in Hadoop 2.x; the base implementation deliberately throws UnsupportedOperationException so subclasses that never overrode it fail loudly. The guaranteed source of the scheme is getUri().getScheme(), since getUri() is abstract and always implemented.","triggerScenarios":"Calling getScheme() on a custom or third-party FileSystem subclass that did not override the method, or generic utility code that calls getScheme() on every FileSystem for registration or capability checks.","commonSituations":"FileSystems written against Hadoop 1.x APIs and recompiled against 2.x+; glue code selecting implementations by comparing schemes.","solutions":["Use fs.getUri().getScheme() instead - it always works","If you own the implementation, override getScheme() to return the registered scheme constant","Restrict direct getScheme() calls to known implementations (DistributedFileSystem, LocalFileSystem, ...)"],"exampleFix":"// before\nString scheme = fs.getScheme(); // UnsupportedOperationException on non-overriding implementations\n\n// after\nString scheme = fs.getUri().getScheme();","handlingStrategy":"fallback","validationCode":"public static String schemeOf(FileSystem fs) {\n  URI u = fs.getUri();\n  return (u == null) ? null : u.getScheme();\n}","typeGuard":null,"tryCatchPattern":"try {\n  scheme = fs.getScheme();\n} catch (UnsupportedOperationException e) {\n  scheme = fs.getUri().getScheme(); // base-class default is unimplemented\n}","preventionTips":["Prefer getUri().getScheme() in generic code","Override getScheme() when implementing a FileSystem","Treat optional 2.x-era FileSystem methods as capability probes, not guarantees"],"tags":["hadoop","filesystem","api-misuse","unsupported-operation"],"backgroundTag":"unsupported-operation-default","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}