Navigation

RSS 2.0 New Entries Syndication Feed Atom 0.3 New Entries Syndication Feed

Show blog menu v

 

General

Use it

Documentation

Support

Sibling projects

RIFE powered

Valid XHTML 1.0 Transitional

Valid CSS!

Blogs : Archives

avatar
< RIFE 1.3.1 released   RIFE/Laszlo 1.3.1 released >
Flaky file URL objects with JDK 1.4 on windows

Beware when you're creating URL instances by providing the entire spec without separating it into protocol, host, and file.

If your URL spec happens to be in the following format:

file://C:/somepath/file

JDK 1.4 will try to lookup the C host name. This will of course fail, but by default it takes 5 minutes to do so on Windows. Imagine what happens when you have several of these URLs ...

To work around this issue, make sure to instantiate your file protocol URLs like this:

String filepath = "C:/somepath/file";
URL url = new URL("file", null, filepath);

This will prevent the JDK from getting confused.

You can find proof of this behavior in this screenshot of a debugging session that Stéphane Meslin-Weber performed to track down slow startup times in RIFE:

This issue seems to have been fixed in JDK 1.5.

Update:

It seems that I jumped to conclusions too quickly and that the correct URL format should have an additional slash:

file:///C:/somepath/file

The confusing part for us was that JDK 1.5 doesn't seem to try to lookup C as a hostname, which made the issue very hard to track down since none of the core RIFE devs use JDK 1.4. We use retroweaver to generate a compatible version.

posted by Geert Bevin in Java on Dec 22, 2005 5:42 PM : 5 comments [permalink]
 

Comments

Re: Flaky file URL objects with JDK 1.4 on windows
Nice screenshot, but where's the profiling (timing) information?
Re: Flaky file URL objects with JDK 1.4 on windows
This screenshot clearly shows that C is looked up as the hostname, the timing isn't shown there though.
Re: Flaky file URL objects with JDK 1.4 on windows
From what I recall, there are four possible URLs that might work and are "legal":

file://localhost/C:/somepath/file
file://localhost/C|/somepath/file
file:///C:/somepath/file
file:///C|/somepath/file

Notice that there are two base options for file URLs:

file://localhost/
file:///

And then an additional two options for specifying the C drive:

C:
C|

Another option to try is:

new File("C:\\somepath\\file").toURI().toURL()

I know, toURI().toURL() seems strange, but that's what the 1.4.2 docs recommend...
Re: Flaky file URL objects with JDK 1.4 on windows
Thanks for the clarifications Kris. It’s confusing then that JDK 1.5 does handle the omission of that third slash without using C as the hostname. Since most of us develop on 1.5 and use retroweaver to create the 1+4 version, this issue was very hard to track down.
Re: Flaky file URL objects with JDK 1.4 on windows
I've had success with this prefix: file:/

as in, file:/c:/blah/blah

There was a peculiarity with file:///blah/blah on aix with the ibm jvm that I can't remember right now.

Add a new comment

:) ;)
=) :-)
:'( :(
:/ :D
:| :p
:o 8)
Your email address will not be displayed at anytime on any page.
Only provide your email address if you'd like updates on this entry
and it's comments by email.
Please answer this simple math question:
18 - 1 = 
 
 
  

Manage subscription

Remove email:
 

< RIFE 1.3.1 released   RIFE/Laszlo 1.3.1 released >
 
 
 
Google
rifers.org web