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

InterruptedException when using JFileChooser

    XMLWordPrintable

    Details

      Description

      Sometimes when constructing and configuring a JFileChooser in our application, an InterruptedException is thrown. The problem is very intermittent (this typically occurs no more than 1/10 tries...sometimes we don't see it for long periods of time which leads us to believe a "fix" has worked, only to see it again later). The following code is being executed to construct and configure the JFileChooser:

              chooser = new JFileChooser( defaultLogDir );
              chooser.setFileSelectionMode( JSemiModalFileChooserC.FILES_ONLY );
              chooser.setMultiSelectionEnabled( true );
              chooser.setFileHidingEnabled( false );

      Later, when the JFileChooser should be displayed, we execute the following code (in the swing thread):

              chooser.setAcceptAllFileFilterUsed( false );
              int returnValue = chooser.showOpenDialog( parentPanel );

      The stracktrace from the exception is:

      java.lang.InterruptedException
                  at javax.swing.filechooser.FileSystemView.getFiles(FileSystemView.java:401)
                  at javax.swing.plaf.basic.BasicDirectoryModel$LoadFilesThread.run(BasicDirectoryModel.java:194)
          java.lang.InterruptedException
                  at sun.awt.shell.ShellFolderManager.createShellFolder(ShellFolderManager.java:26)
                  at sun.awt.shell.ShellFolder.getShellFolder(ShellFolder.java:236)
                  at javax.swing.filechooser.FileSystemView.getShellFolder(FileSystemView.java:486)
                  at javax.swing.filechooser.FileSystemView.getFiles(FileSystemView.java:409)
                  at javax.swing.plaf.basic.BasicDirectoryModel$LoadFilesThread.run(BasicDirectoryModel.java:194)

      My hunch is that this is probably a threading issue. Could this be caused by the fact that the JFileChooser constructor was not called in the swing thread?

      This problem is consistently reproducible at the customer end , but not at our end.
      Hi Kannan

      Here is the exact cut/paste from customer's system

      ncs-039#uname -a
      SunOS ncs-039 5.8 Generic_108528-22 sun4u sparc SUNW,Ultra-60

      cs-039#opt/nortel/3rd_party/java/jre_1.4.2_07/bin/java JFileChooserTest
      got past JFileChooser constructor
      got past setFileSelectionMode()
      got past setMultiSelectionEnabled()
      got past setFileHidingEnabled()
      got past setAcceptAllFileFilterUsed()
      java.lang.InterruptedException
             at javax.swing.filechooser.FileSystemView.getFiles(FileSystemView.java:401)
             at javax.swing.plaf.basic.BasicDirectoryModel$LoadFilesThread.run(BasicDirectoryModel.java:194)
      got past showOpenDialog()
      ncs-039#opt/nortel/3rd_party/java/jre_1.4.2_07/bin/java JFileChooserTest

      Fix is required for 1.5.0_xx

      Thanks,
      Manish

        Attachments

          Activity

            People

            Assignee:
            kbalasubsunw Kannan Balasubramanian (Inactive)
            Reporter:
            duke J. Duke (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: