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

JFileChooser create new folder fails silently

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 9
    • 8u25, 9
    • client-libs
    • b100
    • x86_64
    • windows_7

      FULL PRODUCT VERSION :
      java version "1.8.0_25"
      Java(TM) SE Runtime Environment (build 1.8.0_25-b18)
      Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.1.7601]

      A DESCRIPTION OF THE PROBLEM :
      Using the JFileChooser "Create New Folder" button can fail silently. For example, on Windows when the directory requires admin access to create a new directory and Java is not running with admin access.

      The problem can be fixed by throwing an IOException when mkdirs() fails (returns false) in WindowsFileSystemView.createNewFolder(File), UnixFileSystemView.createNewFolder(File), and GenericFileSystemView.createNewFolder(File).

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run code.

      Navigate file chooser to a directory that requires admin access for writing, such as most subdirectories within "Program Files" on a recent version of Windows.

      Hit the "Create New Folder" button.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Expect an error dialog, ideally saying why the new folder couldn't be created, but at least saying that it could not be.
      ACTUAL -
      The new folder is not created and there is no indication of an error.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import javax.swing.*;

      public class FCTest {
         public static void main(String[] args) {
            SwingUtilities.invokeLater(
                  new Runnable() {
                     public void run() {
                        (new JFileChooser()).showOpenDialog(null);
                     }});
         }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Create and use a FileSystemView wrapper implementation that throws an IOException if the result of createFolder(File) on the wrapped FileSystemView does not exist (was not created).

            rchamyal Rajeev Chamyal (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: