Community
Participate
Working Groups
Problem behavior: the URL returned from FileLocator.toFileURL() can contain spaces. This causes URL.toURI() to fail because spaces should be escaped as %20. Suggested fix: at the very least, doc the toFileURL and getEntry methods to suggest where spaces and other special characters should be escaped. I'm not sure you could introduce correct escaping in toFileURL or getEntry without breaking existing code. To reproduce: BundleContext bundleContext = ...; Bundle bundle = bundleContext.getBundle(); URL bundleUrl = bundle.getEntry( "/resource path with spaces" ); URL fileUrl = FileLocator.toFileURL( bundleUrl ); // fileUrl contains spaces File resourceFile = new File( filUrl.toURI() ); // boom: Caused by: java.net.URISyntaxException: Illegal character in path at index nn: file:/C:/xxxxxx/resource path with spaces at java.net.URI$Parser.fail(URI.java:2809) at java.net.URI$Parser.checkChars(URI.java:2982) at java.net.URI$Parser.parseHierarchical(URI.java:3066) at java.net.URI$Parser.parse(URI.java:3014) at java.net.URI.<init>(URI.java:578) at java.net.URL.toURI(URL.java:918) Cheers, Michael Lossos Software Goodness Limited
Looks like a friend of bug 145096.
Yes, seems like the same as the bug 145096. *** This bug has been marked as a duplicate of bug 145096 ***