|
Duplicate :
|
|
|
Relates :
|
|
|
Relates :
|
|
|
Relates :
|
A DESCRIPTION OF THE PROBLEM :
When you have a shortcut file (*.lnk) on the desktop that points to a location on a network server to which you must authenticate, the JFileChooser is very slow to open and change folders. This occurs in the same case as JDK-8213583 when you have a security manager set. Without a security manager set, changing directories is fast except when changing to the desktop.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Create a shortcut file on your desktop to a network server to which you need to authenticate. You'll know you have this setup correctly if you double click the shortcut and see a "Windows Security" dialog asking you to "Enter your credentials to connect to: <SERVERNAME>"
2. Run the test case file with Java 11 or later
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The file chooser opens quickly and changing directories is fast.
ACTUAL -
The file chooser takes a while to open and changing directories is very slow.
---------- BEGIN SOURCE ----------
import java.io.*;
import javax.swing.JFileChooser;
/////////////////////////////////////
//
// NOTE:
// There must be a shortcut on the Windows desktop referencing a network location
// that requires authentication before running this program.
//
public class SlowLinkBug {
public static void main(String[] args) throws Exception {
// Creates a temporary security policy
final File tempPolicyFile = File.createTempFile("broken-links-bug-", ".policy");
tempPolicyFile.deleteOnExit();
try (final PrintStream policyStream = new PrintStream(new FileOutputStream(tempPolicyFile))) {
policyStream.println("grant { permission java.security.AllPermission; };");
}
System.setProperty("java.security.policy", tempPolicyFile.getAbsolutePath());
// Trigger the problem
System.setSecurityManager(new SecurityManager());
JFileChooser chooser = new JFileChooser();
chooser.showDialog(null, "Open"); // not really needed
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Remove the link from the desktop or don't set a security manager.
FREQUENCY : always
|