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

File.isDirectory() extremely slow with UNC pathname (win)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P5 P5
    • None
    • 6
    • core-libs
    • x86
    • windows_xp

      FULL PRODUCT VERSION :

      Java 1.6.0 with Sun Microsystems Inc. Java HotSpot(TM) Client VM mixed mode

      ADDITIONAL OS VERSION INFORMATION :
      Windows XP

      A DESCRIPTION OF THE PROBLEM :
      When calling File.isDirectory using a UNC pathname performance is extremely slow.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Create a File object using a unc pathname.
      Call File.list() to get a list of filenames in the directory.
      For each filename in the list, create a new
      File("unc pathname", filename")
      and call isDirectory().
      Performance slows to a point it appears application is hung.


      REPRODUCIBILITY :
      This bug can be reproduced always.

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

      public class isdir extends JFrame
      {
          public isdir()
          {
              init();
          }

          private void init()
          {
              File test;
      // substitue a UNC pathname
              File dir = new File( "\\\\mathworks\\public");
              boolean loop = true;
              String[] filelist = null;
      filelist = dir.list(); // get files

             int totalNumFiles = filelist.length;
         
              for (int i = 0; i < totalNumFiles; i++)
              {
      // works fine with a mapped drive
                  // test = new File("p:", filelist[i]);
      // substitue a unc pathname
                     test = new File("\\\\mathworks\\public", filelist[i]);
                     if (test.isDirectory())
                       System.out.println(test.getName() + " is Directory.");
                   else
                       System.out.println(test.getName() + " is not a Directory.");
              }

          }

          public static void main(String[] args)
          {
              isdir frame = new isdir();
          }
      }

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

      CUSTOMER SUBMITTED WORKAROUND :
      Instead of using a UNC pathname, map a drive letter.

            iris Iris Clark
            ryeung Roger Yeung (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: