apache/hadoop · error · UnsupportedOperationException

{} doesn't support getXAttrs

Error message

{} doesn't support getXAttrs

What it means

FileSystem.getXAttrs(Path) (read ALL xattr name/value pairs for a path) is optional; the base class throws UnsupportedOperationException with getClass().getSimpleName() + " doesn't support getXAttrs". Only HDFS-family clients and pass-through wrappers implement bulk xattr reads; local filesystem and S3A/GCS-style connectors throw.

Source

Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java:3304

    throw new UnsupportedOperationException(getClass().getSimpleName()
        + " doesn't support getXAttr");
  }

  /**
   * Get all of the xattr name/value pairs for a file or directory.
   * Only those xattrs which the logged-in user has permissions to view
   * are returned.
   * <p>
   * Refer to the HDFS extended attributes user documentation for details.
   *
   * @param path Path to get extended attributes
   * @return Map describing the XAttrs of the file or directory
   * @throws IOException IO failure
   * @throws UnsupportedOperationException if the operation is unsupported
   *         (default outcome).
   */
  public Map<String, byte[]> getXAttrs(Path path) throws IOException {
    throw new UnsupportedOperationException(getClass().getSimpleName()
        + " doesn't support getXAttrs");
  }

  /**
   * Get all of the xattrs name/value pairs for a file or directory.
   * Only those xattrs which the logged-in user has permissions to view
   * are returned.
   * <p>
   * Refer to the HDFS extended attributes user documentation for details.
   *
   * @param path Path to get extended attributes
   * @param names XAttr names.
   * @return Map describing the XAttrs of the file or directory
   * @throws IOException IO failure
   * @throws UnsupportedOperationException if the operation is unsupported
   *         (default outcome).
   */
  public Map<String, byte[]> getXAttrs(Path path, List<String> names)

View on GitHub (pinned to 2add963021)

Solutions

  1. Probe fs.hasPathCapability(path, CommonPathCapabilities.FS_XATTRS) before the bulk read
  2. Return an empty map for non-supporting stores instead of failing the crawl
  3. distcp: disable xattr preservation (-p without xattr) when either endpoint lacks support
  4. Keep attribute data in an external catalog keyed by path for non-HDFS stores

Example fix

// before
Map<String, byte[]> all = fs.getXAttrs(path); // throws on LocalFileSystem

// after
Map<String, byte[]> all = fs.hasPathCapability(path,
        CommonPathCapabilities.FS_XATTRS)
    ? fs.getXAttrs(path)
    : Collections.emptyMap();
Defensive patterns

Strategy: try-catch

Validate before calling

Map<String, byte[]> xattrs = fs.hasPathCapability(path,
        CommonPathCapabilities.FS_XATTRS)
    ? fs.getXAttrs(path)
    : Collections.emptyMap();

Type guard

static boolean supportsBulkXattrRead(FileSystem fs) {
  return fs instanceof DistributedFileSystem
      || fs instanceof WebHdfsFileSystem;
}

Try / catch

try {
  return fs.getXAttrs(path);
} catch (UnsupportedOperationException e) {
  return Collections.emptyMap(); // crawler-friendly default for xattr-less stores
}

Prevention

When it happens

Trigger: Calling fs.getXAttrs(path) on file://, s3a://, gs://, har:// or a custom FileSystem; 'dump all attributes' utilities, metadata crawlers, or distcp -p xattr preservation enumerating attributes on every path.

Common situations: Metadata harvest for governance/search crawling mixed data lakes; replication tooling that preserves xattrs and hits a non-HDFS destination or source.

Related errors


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/0b8e0baf78d65f45. Report an issue: GitHub.