Details
-
Type:
Improvement
-
Status:
Open
-
Priority:
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();
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