JIRA

  • Log In Access more options
    • Online Help
    • GreenHopper Help
    • Agile Answers
    • Use Agile By Default
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What’s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • Agile Access more options (Alt+g)
  • Create Issue
  • Mule
  • MULE-1313

Implement a workaround for File.toURL() bugs (JDK bug parade ids: 4273532 and 6179468)

  • Agile Board
  • More Actions
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Improvement Improvement
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: 1.3.3
  • Fix Version/s: None
  • Component/s: Core: (other)
  • Labels:
    None
  • Similar Issues:
    None

Description

A nice summary is available at http://www.javalobby.org/java/forums/t19698.html

The behaviour has been fixed in JDK 6 only, so we'll have to provide our own factory method in FileUtils. The caveat is the bootstrap module's classloading process, which can impose its own restrictions on Mule util libraries availability.

Current list of usages (trunk@4668):

Method
toURL():URL of class java.io.File
Found usages (9 usages)
Unclassified usage (9 usages)
AbstractScriptComponent (1 usage)
getScriptUrl(String) (1 usage)
(106, 26) return f.toURL();
ClassLoaderFactory (1 usage)
getUrlsFrom(String, List) (1 usage)
(80, 49) urls[i] = new File(root, cpElement).toURL();
DefaultMuleClassPathConfig (4 usages)
DefaultMuleClassPathConfig(File, File) (4 usages)
(53, 36) addURL(jar.toURL());
(70, 28) addURL(jar.toURL());
(79, 28) addURL(jar.toURL());
(89, 28) addURL(jar.toURL());
IOUtils (1 usage)
getResourceAsUrl(String, Class, boolean) (1 usage)
(154, 50) url = file.getAbsoluteFile().toURL();
LibraryDownloader (2 usages)
copyLibrary(String, String) (1 usage)
(140, 36) return destinationFile.toURL();
downloadLibrary(String, String, String) (1 usage)
(161, 40) return destinationFile.toURL();

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
  • Transitions
  • Commits
  • Source
  • Builds
Hide
Permalink
Holger Hoffstaette added a comment - 14/Jan/07 04:10 AM

Having consistent FileUtils.toURL(File) and FileUtils.toFile(URL) would be nice; replacing all occurrences of aFile.toURL() with the helper and preventing its use even at development time (showing a warning/error) is a typical AspectJ/AJDT use case.

For a start:

public void testToUrl() throws Exception

{ File dir = new File("C:", "Dokumente und Einstellungen"); System.out.println("original : " + dir); URL url = dir.toURL(); System.out.println("toURL : " + url); url = dir.toURI().toURL(); System.out.println("URI->URL : " + url); File fromURL= new File(new URI(url.toExternalForm())); System.out.println("File(URL) : " + fromURL); }

gives:

original : C:\Dokumente und Einstellungen
toURL : file:/C:/Dokumente und Einstellungen/
URI->URL : file:/C:/Dokumente%20und%20Einstellungen/
File(URL) : C:\Dokumente und Einstellungen

Show
Holger Hoffstaette added a comment - 14/Jan/07 04:10 AM Having consistent FileUtils.toURL(File) and FileUtils.toFile(URL) would be nice; replacing all occurrences of aFile.toURL() with the helper and preventing its use even at development time (showing a warning/error) is a typical AspectJ/AJDT use case. For a start: public void testToUrl() throws Exception { File dir = new File("C:", "Dokumente und Einstellungen"); System.out.println("original : " + dir); URL url = dir.toURL(); System.out.println("toURL : " + url); url = dir.toURI().toURL(); System.out.println("URI->URL : " + url); File fromURL= new File(new URI(url.toExternalForm())); System.out.println("File(URL) : " + fromURL); } gives: original : C:\Dokumente und Einstellungen toURL : file:/C:/Dokumente und Einstellungen/ URI->URL : file:/C:/Dokumente%20und%20Einstellungen/ File(URL) : C:\Dokumente und Einstellungen
Hide
Permalink
Andrew Perepelytsya added a comment - 14/Jan/07 11:51 AM

Note that file:/C:/whatever is a result of a JDK bug (only one slash after file), but everybody is used to this behaviour so much by now, that it won't be fixed. In our documentation for file URI's we try to be consistent and tell users to use double forward slashes, and code defensively wherever possible.

Show
Andrew Perepelytsya added a comment - 14/Jan/07 11:51 AM Note that file:/C:/whatever is a result of a JDK bug (only one slash after file), but everybody is used to this behaviour so much by now, that it won't be fixed. In our documentation for file URI's we try to be consistent and tell users to use double forward slashes, and code defensively wherever possible.
Hide
Permalink
Holger Hoffstaette added a comment - 14/Jan/07 11:58 AM

I noticed that and assumed that file: always had only one slash, making the second slash the "root" slash under Unix. Beautiful! What a pathetic bug for a cross-platform library - isn't there some commons-fix for this??
So /tmp would then correctly be file:///tmp/ ?

Show
Holger Hoffstaette added a comment - 14/Jan/07 11:58 AM I noticed that and assumed that file: always had only one slash, making the second slash the "root" slash under Unix. Beautiful! What a pathetic bug for a cross-platform library - isn't there some commons-fix for this?? So /tmp would then correctly be file:///tmp/ ?
Hide
Permalink
Ross Mason added a comment - 29/Nov/08 06:45 PM

Is this still relevant?

Show
Ross Mason added a comment - 29/Nov/08 06:45 PM Is this still relevant?

People

  • Assignee:
    Andrew Perepelytsya
    Reporter:
    Andrew Perepelytsya
Vote (0)
Watch (0)

Dates

  • Created:
    13/Jan/07 07:21 PM
    Updated:
    29/Nov/08 06:45 PM

Agile

  • View on Board
  • Atlassian JIRA (v5.0.7#734-sha1:8ad78a6)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for MuleForge. Try JIRA - bug tracking software for your team.