JDK-5009755 : InternalError is thrown when calling File.listFiles() on a non directory file
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.4.2
  • Priority: P4
  • Status: Closed
  • Resolution: Cannot Reproduce
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2004-03-08
  • Updated: 2005-09-16
  • Resolved: 2005-09-16
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
5.0Resolved
Related Reports
Relates :  
Description
Name: rmT116609			Date: 03/08/2004


FULL PRODUCT VERSION :
java version "1.5.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b32c)
Java HotSpot(TM) Client VM (build 1.5.0-beta-b32c, mixed mode)

java version "1.4.2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28)
Java HotSpot(TM) Client VM (build 1.4.2-b28, mixed mode)


ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows 2000 [Version 5.00.2195]

A DESCRIPTION OF THE PROBLEM :
InternalError is thrown when calling File.listFiles() on a non directory file
When the File is both a shell File and a non directory file then anInternal Error is thrown.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Adapt the files indexes in the code such that file ends up being a non directory file on the test system.
Run code.
Observe error.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Not a Directory to be displayed.
ACTUAL -
InternalError

ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.lang.InternalError: Unable to bind C:\test.txt to parent

	at sun.awt.shell.Win32ShellFolder2.getIShellFolder(Win32ShellFolder2.java:321)

	at sun.awt.shell.Win32ShellFolder2.listFiles(Win32ShellFolder2.java:508)

	at sun.awt.shell.ShellFolder.listFiles(ShellFolder.java:100)

	at Test.main(Test.java:10)

Exception in thread "main"

REPRODUCIBILITY :
This bug can be reproduced always.

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

public class Test {
  public static void main(String[] args) {
    FileSystemView fsv = FileSystemView.getFileSystemView();
    File file = fsv.getHomeDirectory();
    file = file.listFiles()[0].listFiles()[1].listFiles()[7];
    File[] files = file.listFiles();
    System.out.println(files == null ? "Not a Directory" : Arrays.asList(files).toString());
  }
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
check if file is a directory before calling file.listFiles()
(Incident Review ID: 241381) 
======================================================================

Comments
EVALUATION This problem was fixed by fix for CR 5055740 in 5.0.
16-09-2005

CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: mustang
25-09-2004

EVALUATION Win32ShellFolder should return null from listFiles() if isDirectory() is false. ###@###.### 2004-03-30
30-03-2004