United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6780505 java.awt.Desktop.getDesktop().open() fails on shared files with white spaces
JDK-6780505 : java.awt.Desktop.getDesktop().open() fails on shared files with white spaces

Details
Type:
Bug
Submit Date:
2008-12-04
Status:
Open
Updated Date:
2011-04-28
Project Name:
JDK
Resolved Date:
Component:
client-libs
OS:
windows_xp
Sub-Component:
java.awt
CPU:
x86
Priority:
P4
Resolution:
Unresolved
Affected Versions:
6u10
Targeted Versions:

Related Reports

Sub Tasks

Description
FULL PRODUCT VERSION :
java version "1.6.0_10"
Java(TM) SE Runtime Environment (build 1.6.0_10-b33)
Java HotSpot(TM) Client VM (build 11.0-b15, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Versi??n 5.1.2600]

EXTRA RELEVANT SYSTEM CONFIGURATION :
A folder containing a file with white space must be shared.

A DESCRIPTION OF THE PROBLEM :
Calling Desktop.getDesktop.open() for a file on a shared folder containing whites spaces in his name fails. The file exists.
Also discused on http://forums.sun.com/thread.jspa?threadID=5350089.



STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Share a folder.
Put inside two files, "test.txt" and "te st.txt".
Try to open both with Desktop.getDesktop().open().
Calls will be some like this:
open("\\\\myComputer\\sharedFolder\\te st.txt");
open("//myComputer/sharedFolder/te st.txt");


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
File must be open by some program configured on my windows (usually notepad)
ACTUAL -
\\127.0.0.1\tmp\te st.txt
file:////127.0.0.1/tmp/te%20st.txt
exists=true
canRead=true
canWrite=true
Exception in thread "main" java.io.IOException: Failed to open file:////127.0.0.1/tmp/te%20st.txt. Error message: The operation completed successfully.
 
	at sun.awt.windows.WDesktopPeer.ShellExecute(WDesktopPeer.java:59)
	at sun.awt.windows.WDesktopPeer.open(WDesktopPeer.java:36)
	at java.awt.Desktop.open(Desktop.java:254)
	at DesktopTestWithSpaces.main(DesktopTestWithSpaces.java:19)

ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.io.IOException: Failed to open file:////127.0.0.1/tmp/te%20st.txt. Error message: The operation completed successfully.
 
	at sun.awt.windows.WDesktopPeer.ShellExecute(WDesktopPeer.java:59)
	at sun.awt.windows.WDesktopPeer.open(WDesktopPeer.java:36)
	at java.awt.Desktop.open(Desktop.java:254)
	at DesktopTestWithSpaces.main(DesktopTestWithSpaces.java:19)

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
class DesktopTestWithSpaces {
    public static void main(String[] args) throws Exception {
        // this works
        // File file = new File("//127.0.0.1/tmp/test.txt");
 
        // this does not (both files exist)
        File file = new File("//127.0.0.1/tmp/te st.txt");
        URI uri = file.toURI();
        System.out.println(file.getAbsolutePath());
        System.out.println(uri.toString());
        System.out.println("exists=" + file.exists());
        System.out.println("canRead=" + file.canRead());
        System.out.println("canWrite=" + file.canWrite());
        Desktop.getDesktop().open(file);
    }
}

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

CUSTOMER SUBMITTED WORKAROUND :
None found.
Also tried with file.getCanonicalFile(), file.getAbsoluteFile(), with a URI, ....

                                    

Comments
EVALUATION

Seem it meant the shared folder is the folder other network users may access to.
It's not the shared folder like SharedDocuments or like.
                                     
2010-09-02



Hardware and Software, Engineered to Work Together