RFR: 8254876: (fs) NullPointerException not thrown when first argument to Path.of or Paths.get is null
Roger Riggs
rriggs at openjdk.java.net
Mon Nov 2 21:59:55 UTC 2020
On Mon, 2 Nov 2020 20:28:33 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:
> Please review this simple fix to have Path.of(String,String) throw a NullPointerException if the first parameter is null.
src/java.base/unix/classes/sun/nio/fs/UnixFileSystem.java line 264:
> 262: path = first;
> 263: } else {
> 264: if (first == null) {
`Objects.requireNonNull(first)` does this in fewer lines and a bit more explicitly.
Should it be checking `first` always, not just in the case `more.length != 0`?
(It will throw NPE, but not until `UnixPath.normalizeAndCheck(path))`.
-------------
PR: https://git.openjdk.java.net/jdk/pull/1020
More information about the nio-dev
mailing list