{"record":{"id":"94a5e183c75d6ca2","repo":"apache/hadoop","slug":"does-not-support-method","errorCode":null,"errorMessage":"{} does not support method {}","messagePattern":"(.+?) does not support method (.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/AbstractFileSystem.java","lineNumber":1671,"sourceCode":"  @InterfaceStability.Unstable\n  public Path getEnclosingRoot(Path path) throws IOException {\n    makeQualified(path);\n    return makeQualified(new Path(\"/\"));\n  }\n\n  /**\n   * Helper method that throws an {@link UnsupportedOperationException} for the\n   * current {@link FileSystem} method being called.\n   */\n  protected final void methodNotSupported() {\n    // The order of the stacktrace elements is (from top to bottom):\n    //   - java.lang.Thread.getStackTrace\n    //   - org.apache.hadoop.fs.FileSystem.methodNotSupported\n    //   - <the FileSystem method>\n    // therefore, to find out the current method name, we use the element at\n    // index 2.\n    String name = Thread.currentThread().getStackTrace()[2].getMethodName();\n    throw new UnsupportedOperationException(getClass().getCanonicalName() +\n        \" does not support method \" + name);\n  }\n}\n","sourceCodeStart":1653,"sourceCodeEnd":1675,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/AbstractFileSystem.java#L1653-L1675","documentation":"methodNotSupported() is the shared helper both FileSystem and AbstractFileSystem use to reject optional operations the mounted implementation does not override: it builds the message from the implementation's canonical class name plus the calling method's name taken from stack-trace element index 2. Known callers include FileSystem.setQuota / setQuotaByStorageType and AbstractFileSystem.createMultipartUploader. Because the method name comes from a fixed stack depth, an extra wrapper frame between the API method and the helper can make the reported name misleading.","triggerScenarios":"Calling setQuota or setQuotaByStorageType on a filesystem without quota support (local FS, most object stores) via the generic API; invoking createMultipartUploader on filesystems that have not implemented multipart upload (older versions before S3A/ABFS support); any custom FileSystem subclass that delegates unsupported optional methods to this helper.","commonSituations":"Quota-management tooling assumed HDFS and runs against file:// in tests; a committer or uploader library probes createMultipartUploader on whatever FS is configured; subclassed/wrapped FileSystems shift the stack frame so the error names the wrong method, sending debugging in the wrong direction.","solutions":["Read the exception's method name and canonical class to identify which optional operation and which implementation failed; if you use wrapper layers, verify the name against the actual call site since it is derived from stack depth.","Route quota operations to HDFS (HdfsAdmin.setQuota / DistributedFileSystem) and multipart uploads to stores that implement them.","Feature-detect at startup with a try/catch probe and remember the result per filesystem.","For custom FileSystem subclasses, override the optional methods you support rather than relying on the default helper."],"exampleFix":"// before\nfs.setQuota(path, 1000, 1L << 30); // throws \"...does not support method setQuota\" on local FS\n\n// after\nif (fs instanceof DistributedFileSystem) {\n  ((DistributedFileSystem) fs).setQuota(path, 1000, 1L << 30);\n}","handlingStrategy":"try-catch","validationCode":"static boolean supportsQuotas(FileSystem fs, Path probe) {\n  try {\n    fs.setQuota(probe, Long.MAX_VALUE - 1, Long.MAX_VALUE - 1);\n    fs.setQuota(probe, Long.MAX_VALUE, Long.MAX_VALUE); // reset\n    return true;\n  } catch (UnsupportedOperationException e) {\n    return false;\n  } catch (IOException e) {\n    return true;\n  }\n}","typeGuard":"static boolean isHdfsBacked(FileSystem fs) {\n  return fs instanceof DistributedFileSystem;\n}","tryCatchPattern":"try {\n  fs.setQuota(path, nsQuota, ssQuota);\n} catch (UnsupportedOperationException e) {\n  // optional op not implemented by this filesystem: skip or fail with context\n  throw new IOException(\"Quotas unsupported on \" + fs.getUri(), e);\n}","preventionTips":["Do not trust the method name in this message blindly: it is derived from stack depth and wrappers can shift it - correlate with your call site","Probe optional capabilities once and cache per filesystem instance","Prefer the concrete subclass (DistributedFileSystem, HdfsAdmin) for optional HDFS-only operations"],"tags":["hadoop","filesystem","unsupportedoperationexception","optional-api","quota"],"backgroundTag":"unsupported-operation","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}