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

unexpected failure of java.io.File.mkdirs()

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 1.1
    • 1.0
    • other-libs
    • 1.1
    • sparc
    • solaris_2.5
    • Not verified

      I have copy in an applet that is calling java.io.File.mkdirs().

      Because it's in an applet, the AppletSecurityManager is around.

      Through what is arguably an error of mine, I am calling mkdirs()
      twice on the same directory. The results were unexpected to the
      point of warranting this report.

      I was trying to create a directory called /home/jjg/tmp/classes/errors.
      The parent directory /home/jjg/tmp/classes was on my write path.

      The first time I called mkdirs() the call succeeded, naturally enough.

      The second time I called mkdirs, the call failed because /home/jjg/tmp
      was not on my path!!!


      Reading the code, what I think has happened is the following ...

      call mkdirs() ....
      it tries a mkdir()
      this fails because the directory already exists

      however, mkdirs thinks it failed because it couldn't
      create it, so recursively tries to create the parent

      recursively, this fails, so tries to create the parent's parent

      eventually it all falls over in a parent directory that is the parent
      of the one on the write path.


      It would be better if mkdir or mkdirs had an exception for DirectoryAlreadyExists,
      instead of giving this bizarre security fault.

            djbrown David Brown (Inactive)
            jjg Jonathan Gibbons
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: