Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8241620

(zipfs) Files.newByteChannel(zipfile, Set.of(CREATE_NEW, READ)) does not throw a FileAlreadyExistsException when the file exists

    Details

    • Type: Bug
    • Status: Open
    • Priority: P5
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: tbd
    • Component/s: core-libs
    • Labels:
      None

      Description

      The following example will not throw a FileAlreadyExistsException:

          @Test
             public void zipFAETest(final Map<String, String> env,
                                      final int compression) throws Exception {
              Path zipFile = generatePath(HERE, "test", ".zip");
              Files.deleteIfExists(zipFile);
              Entry e0 = Entry.of("Entry-0", compression, THE_SLAMS);
              zip(zipFile, env, e0);

              // Validate that a FileAlreadyExistsException is thrown
              try (FileSystem zipfs = FileSystems.newFileSystem(zipFile, env)) {
                  assertThrows(FileAlreadyExistsException.class, () ->
                          Files.newByteChannel(zipfs.getPath(e0.name), Set.of(CREATE_NEW)));
              }
              Files.deleteIfExists(zipFile);
          }



      If you specify Set.of(CREATE_NEW, WRITE) you will get the expected Exception

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                lancea Lance Andersen
                Reporter:
                lancea Lance Andersen
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated: