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

(zipfs) newFileSystem​() should not throw FileSystemAlreadyExistsException

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: 11, 12, 13
    • Fix Version/s: tbd
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      windows_7

      Description

      A DESCRIPTION OF THE PROBLEM :
      It appears FileSystemProvider.newFileSystem(Path, Map) always creates new FileSystem objects, because:
      - It does not declare that it throws FileSystemAlreadyExistsException
      - FileSystemProvider.getFileSystem(URI) says that these file system will not be returned (there is also a typo "File systems created the" -> "File systems created **by** the")
      - ZipFileSystemProvider creates a new file system

      If this is the case it should be more clearly documented and the documentation should also explain the implications of this:
      What does this mean for FileSystemProviders which normally throw a FileSystemAlreadyExistsException when a FileSystem for the same resource is requested? Can the use of these multiple FileSystem instances corrupt the resource?


      ---------- BEGIN SOURCE ----------
      // Change this to a local zip file
      String pathToZip = "path/to/file.zip";
      URI uri = URI.create("jar:file:/" + pathToZip + "!/");
      Path path = Paths.get(pathToZip);

      FileSystem a = FileSystems.newFileSystem(path, null);
      FileSystem b = FileSystems.newFileSystem(uri, Collections.emptyMap());

      System.out.println("a == b: " + (a == b));
      System.out.println("a: " + a + ", b: " + b);
      System.out.println("Providers ==: " + (a.provider() == b.provider()));

      // Creates second FileSystem for the same resource
      FileSystem a2 = FileSystems.newFileSystem(path, null);
      System.out.println("a == a2: " + (a == a2));

      // Throws FileSystemAlreadyExistsException, as expected
      FileSystem b2 = FileSystems.newFileSystem(uri, Collections.emptyMap());
      ---------- END SOURCE ----------

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              lancea Lance Andersen
              Reporter:
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: