Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 338491 - URLClassLoader getFilePath() use of URLDecoder.decode(path, "utf-8") is wrong
Summary: URLClassLoader getFilePath() use of URLDecoder.decode(path, "utf-8") is wrong
Status: VERIFIED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: BIRT (show other bugs)
Version: 2.5.0   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: 3.7.0 M7   Edit
Assignee: Jun Ouyang CLA
QA Contact: Xiaoying Gu CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-28 18:45 EST by Michael Vorburger CLA
Modified: 2011-04-11 22:53 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Vorburger CLA 2011-02-28 18:45:15 EST
I have run into an issue with BIRT with used in Mifos (http://mifos.org), detailed in http://mifosforge.jira.com/browse/MIFOS-4765.

It appears that BIRT (version 2.5.0 used in Mifos) is unable to load the org.eclipse.osgi_3.5.0.v20090520.jar when it is in a packaged WAR's WEB-INF/lib, if the Servlet Container temporary directory (which the OSGi JAR gets copied into) contains e.g. '+' characters (which is common for temporary directories on Mac OS X).

I've debugged this and seen that this is because org.eclipse.birt.core.framework.URLClassLoader's getFilePath() uses URLDecoder.decode( path, "utf-8" ) which removes the '+' characters, and then the JAR can't be loaded.

The purpose of this issue to suggest to the BIRT development team that using URLDecoder.decode(path, "utf-8") in org.eclipse.birt.core.framework.URLClassLoader's getFilePath() is plain simply buggy IMHO - a local filesystem (temporary) directory name is not an URL? I'd argue that URLDecoder.decode() should be either removed or replaced by a more suitable API (but am unclear what the original intention of that decode in that method actually was - but then have only stumbled upon that code, and may well miss the overall purpose).

The workaround used in Mifos is to set a suitable (i.e. "no '+' characters") WAR temp directory, that solves this; I've tested it via programmatic warCtx.setTempDirectory() in an Embedded Jetty test case as well as with mkdir $JETTY_HOME/work in a standalone Jetty (http://docs.codehaus.org/display/JETTY/Temporary+Directories).
Comment 1 Jun Ouyang CLA 2011-03-30 04:56:35 EDT
Don't invoke URLDecoder.decode( path, "utf-8" ) to get file path, it's unnecessary.
Comment 2 Jun Ouyang CLA 2011-04-06 21:57:35 EDT
Use custom decoding method instead of URLDecoder.decode() to decode file path in url. The method will ignore character '+' and acts exactly same as URLClassLoader of java does.

Please notice that paths containing character '%' can't be supported either.
Comment 3 Xiaoying Gu CLA 2011-04-11 22:53:20 EDT
Verified in daily build 3.7.0.v20110412-0630