mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-18 10:04:42 +02:00
8274276: Cache normalizedBase URL in URLClassPath.FileLoader
Reviewed-by: dfuchs
This commit is contained in:
parent
b36881fa3b
commit
94f5e807c9
1 changed files with 4 additions and 3 deletions
|
@ -597,7 +597,7 @@ public class URLClassPath {
|
||||||
/*
|
/*
|
||||||
* Returns the base URL for this Loader.
|
* Returns the base URL for this Loader.
|
||||||
*/
|
*/
|
||||||
URL getBaseURL() {
|
final URL getBaseURL() {
|
||||||
return base;
|
return base;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1199,7 +1199,8 @@ public class URLClassPath {
|
||||||
*/
|
*/
|
||||||
private static class FileLoader extends Loader {
|
private static class FileLoader extends Loader {
|
||||||
/* Canonicalized File */
|
/* Canonicalized File */
|
||||||
private File dir;
|
private final File dir;
|
||||||
|
private final URL normalizedBase;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Creates a new FileLoader for the specified URL with a file protocol.
|
* Creates a new FileLoader for the specified URL with a file protocol.
|
||||||
|
@ -1209,6 +1210,7 @@ public class URLClassPath {
|
||||||
String path = url.getFile().replace('/', File.separatorChar);
|
String path = url.getFile().replace('/', File.separatorChar);
|
||||||
path = ParseUtil.decode(path);
|
path = ParseUtil.decode(path);
|
||||||
dir = (new File(path)).getCanonicalFile();
|
dir = (new File(path)).getCanonicalFile();
|
||||||
|
normalizedBase = new URL(getBaseURL(), ".");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1227,7 +1229,6 @@ public class URLClassPath {
|
||||||
Resource getResource(final String name, boolean check) {
|
Resource getResource(final String name, boolean check) {
|
||||||
final URL url;
|
final URL url;
|
||||||
try {
|
try {
|
||||||
URL normalizedBase = new URL(getBaseURL(), ".");
|
|
||||||
url = new URL(getBaseURL(), ParseUtil.encodePath(name, false));
|
url = new URL(getBaseURL(), ParseUtil.encodePath(name, false));
|
||||||
|
|
||||||
if (url.getFile().startsWith(normalizedBase.getFile()) == false) {
|
if (url.getFile().startsWith(normalizedBase.getFile()) == false) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue