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

(jrtfs) Calling Files.exists may break the JRT filesystem

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 17
    • Fix Version/s: 17
    • Component/s: tools
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      b23

      Description

      Consider this code (also attached):
      ---
      package jrtfstest;

      import java.net.URI;
      import java.nio.file.FileSystems;
      import java.nio.file.Files;
      import java.nio.file.Path;

      public class JRTFSTest {

          public static void main(String[] args) throws Exception {
              Path p = FileSystems.getFileSystem(new URI("jrt:///")).getPath("modules");
              boolean wasDirectory = Files.isDirectory(p);
              Path m = p.resolve("modules");
              Files.exists(m);
              if (wasDirectory != Files.isDirectory(p)) {
                  throw new AssertionError("The status of 'p' changed from: " + wasDirectory +
                                            " to: " + Files.isDirectory(p));
              }
          }
          
      }
      ---

      Running like this:
      ---
      $ java /tmp/JavaApplication71/src/jrtfstest/JRTFSTest.java
      Exception in thread "main" java.lang.AssertionError: The status of 'p' changed from: true to: false
              at jrtfstest.JRTFSTest.main(JRTFSTest.java:17)
      ---

      By calling Files.exists on "m", the result from Files.isDirectory for "p" changed - that does not seem right.

      This was found while evaluating why this test fails:
      https://github.com/apache/netbeans/blob/903b73c7ed9284df976f3ba466e8696b51d64167/java/classfile/test/unit/src/org/netbeans/modules/classfile/ModuleTest.java#L209

      I think the test was originally trying to work on various old development versions of JRT FS, so was trying to determine whether "modules" directory exists or not, but it breaks the filesystem.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              sundar Sundararajan Athijegannathan
              Reporter:
              jlahoda Jan Lahoda
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: