-
Bug
-
Resolution: Fixed
-
P3
-
1.4.2, 1.4.2_04, 5.0
-
06
-
x86
-
windows_2000, windows_xp
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2119575 | 5.0 | Leif Samuelsson | P3 | Resolved | Fixed | b57 |
Name: rmT116609 Date: 05/27/2003
FULL PRODUCT VERSION :
java version "1.4.2-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-beta-b19)
Java HotSpot(TM) Client VM (build 1.4.2-beta-b19, mixed mode)
FULL OS VERSION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
JFileChooser.setCurrentDirectory() will produce a NullPointerException if
called twice with a non-canonical file. This happens in the "LoadFilesThread".
FileSystemView really needs to be made bulletproof to prevent this kind of
thing. Many of the methods of FileSystemView are quite flaky, and require a
canonical file and/or an existing file, although this is not documented.
JFileChooser and other users of FileSystemView should not be required to
work around this voodoo.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run code.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Expect nothing.
ACTUAL -
Get what is apparently a debugging dump of a
FileNotFoundException, followed by a (thrown) NullPointerException.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
FileSystemView.getShellFolder: f=C:\Windows\.\System
java.io.FileNotFoundException: Could not find file C:\Windows\.\System
at sun.awt.shell.Win32ShellFolder2.parseDisplayName(Win32ShellFolder2.java:574)
at sun.awt.shell.Win32ShellFolderManager2.createShellFolder(Win32ShellFolderManager2.java:40)
at sun.awt.shell.Win32ShellFolderManager2.createShellFolder(Win32ShellFolderManager2.java:36)
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)
java.lang.NullPointerException
at javax.swing.filechooser.FileSystemView.getFiles(FileSystemView.java:412)
at javax.swing.plaf.basic.BasicDirectoryModel$LoadFilesThread.run(BasicDirectoryModel.java:194)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.*;
import java.io.File;
public class JFileChooserBug3 {
public static void main(String args[]) {
JFileChooser fc = new JFileChooser();
File f = new File("C:\\Windows\\.\\System");
fc.setCurrentDirectory(f);
fc.setCurrentDirectory(f);
}
}
---------- END SOURCE ----------
Release Regression From : 1.4.1_02
The above release value was the last known release where this
bug was known to work. Since then there has been a regression.
(Review ID: 186439)
======================================================================
BEA has reported the same issue. Here is the description:
Problem:
If you try to import a libarary with ".." in the path you get the NPE shown
below.
===
NPE
===
java.lang.NullPointerException
at javax.swing.filechooser.FileSystemView.getFiles(FileSystemView.java:419)
at
com.bea.ide.swing.FileSystemViewWrapper.getFiles(FileSystemViewWrapper.java:66)
at
javax.swing.plaf.basic.BasicDirectoryModel$LoadFilesThread.run(BasicDirectoryModel.java:194)
-----------------------------------------------------------------------------------------------
I believe it's the same issue as bug parade 4869950
http://developer.java.sun.com/developer/bugParade/bugs/4869950.html
here is my repro:
import java.awt.*;
import java.awt.event.*;
import java.io.File;
import javax.swing.*;
public class Test2
{
static public void main(String[] args)
{
final JFrame m = new JFrame("main");
JButton b1 = new JButton("open file dialog");
m.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
m.setContentPane(b1);
m.setSize(200,150);
m.setVisible(true);
b1.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
JFileChooser fc = new JFileChooser();
File f = new File("c:\\Documents And Settings\\..");
fc.setCurrentDirectory(f);
fc.setCurrentDirectory(f);
fc.showOpenDialog(m);
}
});
}
}
to see the other call stack, you can type in c:\documents and
settings\..\foo.txt (or some file that exists at your root. and hit open.
this will throw the GetFiles() NPE
java.lang.NullPointerException
at javax.swing.filechooser.FileSystemView.getFiles(FileSystemView.java:419)
at
javax.swing.plaf.basic.BasicDirectoryModel$LoadFilesThread.run(BasicDirectoryModel.java:194)
FULL PRODUCT VERSION :
java version "1.4.2-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-beta-b19)
Java HotSpot(TM) Client VM (build 1.4.2-beta-b19, mixed mode)
FULL OS VERSION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
JFileChooser.setCurrentDirectory() will produce a NullPointerException if
called twice with a non-canonical file. This happens in the "LoadFilesThread".
FileSystemView really needs to be made bulletproof to prevent this kind of
thing. Many of the methods of FileSystemView are quite flaky, and require a
canonical file and/or an existing file, although this is not documented.
JFileChooser and other users of FileSystemView should not be required to
work around this voodoo.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run code.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Expect nothing.
ACTUAL -
Get what is apparently a debugging dump of a
FileNotFoundException, followed by a (thrown) NullPointerException.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
FileSystemView.getShellFolder: f=C:\Windows\.\System
java.io.FileNotFoundException: Could not find file C:\Windows\.\System
at sun.awt.shell.Win32ShellFolder2.parseDisplayName(Win32ShellFolder2.java:574)
at sun.awt.shell.Win32ShellFolderManager2.createShellFolder(Win32ShellFolderManager2.java:40)
at sun.awt.shell.Win32ShellFolderManager2.createShellFolder(Win32ShellFolderManager2.java:36)
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)
java.lang.NullPointerException
at javax.swing.filechooser.FileSystemView.getFiles(FileSystemView.java:412)
at javax.swing.plaf.basic.BasicDirectoryModel$LoadFilesThread.run(BasicDirectoryModel.java:194)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.*;
import java.io.File;
public class JFileChooserBug3 {
public static void main(String args[]) {
JFileChooser fc = new JFileChooser();
File f = new File("C:\\Windows\\.\\System");
fc.setCurrentDirectory(f);
fc.setCurrentDirectory(f);
}
}
---------- END SOURCE ----------
Release Regression From : 1.4.1_02
The above release value was the last known release where this
bug was known to work. Since then there has been a regression.
(Review ID: 186439)
======================================================================
BEA has reported the same issue. Here is the description:
Problem:
If you try to import a libarary with ".." in the path you get the NPE shown
below.
===
NPE
===
java.lang.NullPointerException
at javax.swing.filechooser.FileSystemView.getFiles(FileSystemView.java:419)
at
com.bea.ide.swing.FileSystemViewWrapper.getFiles(FileSystemViewWrapper.java:66)
at
javax.swing.plaf.basic.BasicDirectoryModel$LoadFilesThread.run(BasicDirectoryModel.java:194)
-----------------------------------------------------------------------------------------------
I believe it's the same issue as bug parade 4869950
http://developer.java.sun.com/developer/bugParade/bugs/4869950.html
here is my repro:
import java.awt.*;
import java.awt.event.*;
import java.io.File;
import javax.swing.*;
public class Test2
{
static public void main(String[] args)
{
final JFrame m = new JFrame("main");
JButton b1 = new JButton("open file dialog");
m.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
m.setContentPane(b1);
m.setSize(200,150);
m.setVisible(true);
b1.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
JFileChooser fc = new JFileChooser();
File f = new File("c:\\Documents And Settings\\..");
fc.setCurrentDirectory(f);
fc.setCurrentDirectory(f);
fc.showOpenDialog(m);
}
});
}
}
to see the other call stack, you can type in c:\documents and
settings\..\foo.txt (or some file that exists at your root. and hit open.
this will throw the GetFiles() NPE
java.lang.NullPointerException
at javax.swing.filechooser.FileSystemView.getFiles(FileSystemView.java:419)
at
javax.swing.plaf.basic.BasicDirectoryModel$LoadFilesThread.run(BasicDirectoryModel.java:194)
- backported by
-
JDK-2119575 NPE if JFileChooser.setCurrentDirectory() called twice with non-canonical file
- Resolved
- duplicates
-
JDK-5105436 FileSystemView getParentDirectory() crashes for file "."
- Closed
- relates to
-
JDK-6192278 1.4.2: File.getCanonicalPath() fails for removeable drive if no media is present (win)
- Closed
-
JDK-4470177 JFileChooser constructor behaves erratically on "." as argument
- Closed
-
JDK-4765316 REGRESSION: FileSystemView.getFiles() no longer works with relative paths
- Closed