{"record":{"id":"1488a676174adda7","repo":"apache/hadoop","slug":"does-not-support-listcorruptfileblocks","errorCode":null,"errorMessage":"{} does not support listCorruptFileBlocks","messagePattern":"(.+?) does not support listCorruptFileBlocks","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java","lineNumber":2099,"sourceCode":"      if (filter.accept(listing[i].getPath())) {\n        results.add(listing[i]);\n      }\n    }\n  }\n\n  /**\n   * List corrupted file blocks.\n   *\n   * @param path the path.\n   * @return an iterator over the corrupt files under the given path\n   * (may contain duplicates if a file has more than one corrupt block)\n   * @throws UnsupportedOperationException if the operation is unsupported\n   *         (default).\n   * @throws IOException IO failure\n   */\n  public RemoteIterator<Path> listCorruptFileBlocks(Path path)\n    throws IOException {\n    throw new UnsupportedOperationException(getClass().getCanonicalName() +\n        \" does not support listCorruptFileBlocks\");\n  }\n\n  /**\n   * Filter files/directories in the given path using the user-supplied path\n   * filter.\n   * <p>\n   * Does not guarantee to return the List of files/directories status in a\n   * sorted order.\n   *\n   * @param f\n   *          a path name\n   * @param filter\n   *          the user-supplied path filter\n   * @return an array of FileStatus objects for the files under the given path\n   *         after applying the filter\n   * @throws FileNotFoundException when the path does not exist\n   * @throws IOException see specific implementation","sourceCodeStart":2081,"sourceCodeEnd":2117,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java#L2081-L2117","documentation":"FileSystem.listCorruptFileBlocks(Path) is an optional API: the base implementation in FileSystem.java throws UnsupportedOperationException naming the concrete class. Only HDFS-backed filesystems implement it (Hdfs/DistributedFileSystem ask the NameNode for files whose blocks were found corrupt by DataNode block scanners; FilterFileSystem/FilterFs merely forward to the wrapped FS). The message deliberately names the class so you can see exactly which implementation lacks the capability.","triggerScenarios":"Calling fs.listCorruptFileBlocks(path) on any implementation that does not override it: LocalFileSystem/RawLocalFileSystem (file://), HarFileSystem, S3A, ABFS, GCS connectors, or a ViewFileSystem mount over a non-HDFS store. Also reached via FileContext.listCorruptFileBlocks or AbstractFileSystem defaults on such stores.","commonSituations":"Monitoring/fsck-like tooling written against hdfs:// is repointed at file:// or s3a:// via fs.defaultFS during unit tests or a migration; an ops script enumerates corrupt blocks against the wrong scheme; wrapper filesystems (checksum, view) that delegate to an unsupported inner FS.","solutions":["Run the call only on an HDFS-backed client: guard with fs instanceof DistributedFileSystem","Probe the capability first: fs.hasPathCapability(path, CommonPathCapabilities.FS_LIST_CORRUPT_FILE_BLOCKS) (Hadoop 3.3.1+; default probe returns false rather than throwing)","Catch UnsupportedOperationException and degrade gracefully (skip corrupt-block reporting for this store) — never retry it","For ad-hoc checks use 'hdfs fsck <path> -list-corruptfileblocks' against the HDFS cluster instead of the client API"],"exampleFix":"// before\nRemoteIterator<Path> corrupt = fs.listCorruptFileBlocks(dir);\n// throws UnsupportedOperationException on file://, s3a://, har://\n\n// after\nif (fs.hasPathCapability(dir,\n        CommonPathCapabilities.FS_LIST_CORRUPT_FILE_BLOCKS)) {\n  RemoteIterator<Path> corrupt = fs.listCorruptFileBlocks(dir);\n} else {\n  LOG.warn(\"listCorruptFileBlocks unsupported on {}\", fs.getUri());\n}","handlingStrategy":"try-catch","validationCode":"import org.apache.hadoop.fs.CommonPathCapabilities;\n\nif (fs.hasPathCapability(dir,\n        CommonPathCapabilities.FS_LIST_CORRUPT_FILE_BLOCKS)) {\n  RemoteIterator<Path> it = fs.listCorruptFileBlocks(dir);\n  // safe to consume\n}","typeGuard":"static boolean supportsCorruptBlockListing(FileSystem fs) {\n  return fs instanceof DistributedFileSystem;\n}","tryCatchPattern":"try {\n  RemoteIterator<Path> it = fs.listCorruptFileBlocks(dir);\n} catch (UnsupportedOperationException e) {\n  // capability is absent on this implementation: skip, never retry\n  LOG.warn(\"listCorruptFileBlocks unsupported on {}: {}\", fs.getUri(), e.getMessage());\n}","preventionTips":["Pass explicit hdfs:// paths to HDFS-only tooling instead of relying on fs.defaultFS","In unit tests, stub listCorruptFileBlocks or assert the capability rather than hitting the real base class","Treat UnsupportedOperationException as permanent — log and degrade, do not add retry loops"],"tags":["hadoop","filesystem","hdfs","unsupportedoperationexception","corrupt-blocks","block-scanner","capability"],"backgroundTag":"filesystem-unsupported-operation","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}