RFR: 8292140: (fs) Confusing instanceof check in RegistryFileTypeDetector

Alan Bateman alanb at openjdk.org
Wed Aug 10 05:52:34 UTC 2022


On Mon, 8 Aug 2022 19:51:39 GMT, Andrey Turbanov <aturbanov at openjdk.org> wrote:

> Type of `file` parameter is known to be `Path`. And `instanceof` only checks if it's `null` or not.
> https://github.com/openjdk/jdk/blob/2712bc3f79990f27fe9a624a7a818ba1c2c74b67/src/java.base/windows/classes/sun/nio/fs/RegistryFileTypeDetector.java#L43-L46
> Before `implProbeContentType` method  is called, parameter is checked for null in `sun.nio.fs.AbstractFileTypeDetector#probeContentType`. It means null check is redundant too.
> 
> https://github.com/openjdk/jdk/blob/eb8b789015c98cb5fe7ba788e71f3f6166884739/src/java.base/share/classes/sun/nio/fs/AbstractFileTypeDetector.java#L72-L75

Marked as reviewed by alanb (Reviewer).

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

PR: https://git.openjdk.org/jdk/pull/9797


More information about the nio-dev mailing list