RFR: 8305945: (zipfs) Opening a directory to get input stream produces incorrect exception message [v5]

Alan Bateman alanb at openjdk.org
Sat Apr 15 05:45:34 UTC 2023


On Sat, 15 Apr 2023 00:36:35 GMT, Lance Andersen <lancea at openjdk.org> wrote:

>> Please review this trivial change when ZipFS returns the wrong java.nio.file.FileSystemException message due the the parameters being reversed.
>> 
>> I also included a simple junit test as part of the fix.
>> 
>> Mach5 tiers1-3 are clean
>> 
>> Best
>> Lance
>
> Lance Andersen has updated the pull request incrementally with one additional commit since the last revision:
> 
>   re-arrage assertEquals params

test/jdk/jdk/nio/zipfs/ZipFSDirectoryExceptionMessageTest.java line 96:

> 94:             var file = zipfs.getPath(DIRECTORY_NAME);
> 95:             var x = assertThrows(FileSystemException.class, () -> Files.newInputStream(file));
> 96:             assertEquals(DIR_EXCEPTION_MESSAGE, x.getMessage());

FYI, test doesn't need to depend the exception message. Checking FileSystemException::getOtherFile returns null would be a more robust way of checking that it didn't provide a second file by mistake, e.g.

       try {
            Files.newInputStream(DIRECTORY_NAME);
            fail();
        } catch (FileSystemException e) {
            assertNull(e.getOtherFile());
        } catch (IOException ioe) { 
            // allowed
        }

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

PR Review Comment: https://git.openjdk.org/jdk/pull/13482#discussion_r1167384199


More information about the core-libs-dev mailing list