8344908: URLClassPath should not propagate IllegalArgumentException when finding resources in classpath URLs

Reviewed-by: alanb
This commit is contained in:
Jaikiran Pai 2024-11-28 07:54:00 +00:00
parent ce9d543eb1
commit 81c44e5eb4
5 changed files with 225 additions and 22 deletions

View file

@ -903,7 +903,11 @@ public class URLClassPath {
private FileLoader(URL url) throws IOException {
super(url);
String path = url.getFile().replace('/', File.separatorChar);
path = ParseUtil.decode(path);
try {
path = ParseUtil.decode(path);
} catch (IllegalArgumentException iae) {
throw new IOException(iae);
}
dir = (new File(path)).getCanonicalFile();
@SuppressWarnings("deprecation")
var _unused = normalizedBase = new URL(getBaseURL(), ".");

View file

@ -171,6 +171,7 @@ public final class ParseUtil {
* Returns a new String constructed from the specified String by replacing
* the URL escape sequences and UTF8 encoding with the characters they
* represent.
* @throws IllegalArgumentException if {@code s} could not be decoded
*/
public static String decode(String s) {
int n = s.length();