RFR: 8290047: (fs) FileSystem.getPathMatcher does not check for ":" at last index [v3]

Brian Burkhalter bpb at openjdk.org
Mon Aug 1 20:03:14 UTC 2022


On Mon, 1 Aug 2022 17:32:28 GMT, Roger Riggs <rriggs at openjdk.org> wrote:

> The existing code downstream of the check handles an empty glob or regex pattern as matching the empty string. If I read it correctly, it will now throw an exception instead of not matching. It might be safer to not change that behavior.

Indeed for this code

        FileSystem fs = ...;
        PathMatcher pm = fs.getPathMatcher("glob:");
        System.out.println(pm.matches(Path.of("")));

without the proposed change `true` is printed but with the change an `IllegalArgumentException` is thrown so it would be safer to change

        if (pos <= 0 || pos == syntaxAndInput.length())

to

        if (pos <= 0)

as originally suggested.

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

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


More information about the nio-dev mailing list