RFR: 8346722: (fs) Files.probeContentType throws ClassCastException with custom file system provider

Alan Bateman alanb at openjdk.org
Fri Jan 10 12:41:46 UTC 2025


On Thu, 9 Jan 2025 20:56:20 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

> Ensure the file type detection works with a custom default file system provider.

src/java.base/unix/classes/sun/nio/fs/DefaultFileTypeDetector.java line 36:

> 34: 
> 35:     public static FileTypeDetector create() {
> 36:         FileSystemProvider provider = FileSystems.getDefault().provider();

I assume the imports can be pruned now.

test/jdk/java/nio/file/spi/testapp/testapp/Main.java line 65:

> 63:         String fileType = Files.probeContentType(Path.of("."));
> 64:         if (fileType != null)
> 65:             throw new RuntimeException("File type non-null: " + fileType);

Calling Files.probeContentType is enough to exercise the code, I would be worried that it returns something based on the name of the directory, is that possible?

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/23019#discussion_r1910321513
PR Review Comment: https://git.openjdk.org/jdk/pull/23019#discussion_r1910323722


More information about the nio-dev mailing list