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

REGRESSION:NullPointerException throws when bring up the FileChooser

    XMLWordPrintable

Details

    • x86
    • windows_xp, windows_vista

    Description

      J2SE Version (please include all output from java -version flag):

      java version "1.6.0_19-ea"
      Java(TM) SE Runtime Environment (build 1.6.0_19-ea-b01)
      Java HotSpot(TM) Client VM (build 16.2-b01, mixed mode, sharing)

      Does this problem occur on J2SE 1.4.x or 5.0.x ? Yes / No (pick one)
      No exception on 6.0 update 18


      Operating System Configuration Information (be specific):
      Windows Vista Business SP1

      Hardware Configuration Information (be specific):
      HP Pavillion dv9000
      Windows Vista Business SP1 32 bit
      3 GB RAM
      Intel Core 2 Duo T9300



      Bug Description:
      11:45:54[00007:-4] dsi.client.module.DefaultExceptionHandler.uncaughtException(DefaultExceptionHandler.java:37)Uncaught exception in thread 7'Thread[Basic L&F File Loading Thread,6,main]'
      ---- 1 ---- Throwable - Class (class java.lang.NullPointerException) V(4.06.-01) ----
              ---- Message (null) ----
              at sun.awt.shell.Win32ShellFolder2.hasAttribute(Win32ShellFolder2.java:523)
              at sun.awt.shell.Win32ShellFolder2.isDirectory(Win32ShellFolder2.java:596)
              at javax.swing.filechooser.WindowsFileSystemView.isTraversable(FileSystemView.java:632)
              at javax.swing.JFileChooser.isTraversable(JFileChooser.java:1561)
              at javax.swing.plaf.basic.BasicDirectoryModel$LoadFilesThread.run0(BasicDirectoryModel.java:232)
              at javax.swing.plaf.basic.BasicDirectoryModel$LoadFilesThread.run(BasicDirectoryModel.java:211)



      Steps to Reproduce (be specific):

      Here is a code piece that I used to bring up the FileChooser.


      JFileChooser fileDialog = null;
      fileDialog = new JFileChooser() {
      @Override
      public void approveSelection() {
      File file = getSelectedFile();
      if (file.exists() && file.isFile() && getDialogType() == JFileChooser.SAVE_DIALOG) {
      int answer = JOptionPane.showConfirmDialog(this, file + " exists. Overwrite?", "Overwrite?",
      JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
      if (answer != JOptionPane.OK_OPTION) {
      return;
      }
      }
      super.approveSelection();
      }
      };
      if (includeSearchAccessory)
      fileDialog.setAccessory(new ChooserSearchAccessory(fileDialog));
      fileDialog.setDialogType(type);
      fileDialog.setFileSelectionMode(mode);
      if (defaultDirectory != null)
      fileDialog.setCurrentDirectory(defaultDirectory);
      if (defaultFile != null)
      fileDialog.setSelectedFile(defaultFile);
      fileDialog.setMultiSelectionEnabled(false);
      if (filters != null) {
      for (int i = 0; i < filters.length; i++)
      fileDialog.addChoosableFileFilter(filters[i]);
      }

      if (includeAcceptAll)
      fileDialog.setFileFilter(fileDialog.getAcceptAllFileFilter());
      else
      fileDialog.removeChoosableFileFilter(fileDialog.getAcceptAllFileFilter());
      int value = JFileChooser.CANCEL_OPTION;
      if (type == JFileChooser.CUSTOM_DIALOG)
      value = fileDialog.showDialog(parent, approveButtonText);
      else if (type == JFileChooser.OPEN_DIALOG)
      value = fileDialog.showOpenDialog(parent);
      else if (type == JFileChooser.SAVE_DIALOG)
      value = fileDialog.showSaveDialog(parent);
      Same problem reported by another CAP member:
      -----------------------------------------------------------
      With the Java version 1.6.0_19ea I receive the follow exception on the console. Because I have never see it on the previous version it is a regression. The problem occur on open the file chooser a second time and follows. The file that produce the exception are ever different. In the GUI there seems all ok. Only on the console this exception is to see.
       

      Exception in thread "Basic L&F File Loading Thread" java.lang.NullPointerException

      at sun.awt.shell.Win32ShellFolder2.hasAttribute(Unknown Source)

      at sun.awt.shell.Win32ShellFolder2.isDirectory(Unknown Source)

      at com.inet.report.config.datasource.swing.DataSourceEditor$11.accept(DataSourceEditor.java:756)

      at javax.swing.JFileChooser.accept(Unknown Source)

      at javax.swing.plaf.basic.BasicDirectoryModel$LoadFilesThread.run0(Unknown Source)

      at javax.swing.plaf.basic.BasicDirectoryModel$LoadFilesThread.run(Unknown Source)


      Our code is:

      fileChooser.setFileFilter(new FileFilter(){

      @Override

      public boolean accept(File f) {

      if( f.isDirectory() ){

       return true;

      }

       if( f.getName().endsWith("xml") ){

       return true;

       }

      return false;

       }

       @Override

       public String getDescription() {

       return "XML File";

       }

       });

       



      Steps to Reproduce (be specific):

      Attachments

        Issue Links

          Activity

            People

              rupashka Pavel Porvatov (Inactive)
              tyao Ting-Yun Ingrid Yao (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: