mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8294626: Improve URL protocol lower casing
Reviewed-by: dfuchs
This commit is contained in:
parent
052a924985
commit
3efbd5f0fa
3 changed files with 22 additions and 11 deletions
|
@ -440,7 +440,7 @@ public final class URL implements java.io.Serializable {
|
|||
}
|
||||
}
|
||||
|
||||
protocol = toLowerCase(protocol);
|
||||
protocol = lowerCaseProtocol(protocol);
|
||||
this.protocol = protocol;
|
||||
if (host != null) {
|
||||
|
||||
|
@ -633,7 +633,7 @@ public final class URL implements java.io.Serializable {
|
|||
for (i = start ; !aRef && (i < limit) &&
|
||||
((c = spec.charAt(i)) != '/') ; i++) {
|
||||
if (c == ':') {
|
||||
String s = toLowerCase(spec.substring(start, i));
|
||||
String s = lowerCaseProtocol(spec.substring(start, i));
|
||||
if (isValidProtocol(s)) {
|
||||
newProtocol = s;
|
||||
start = i + 1;
|
||||
|
@ -1384,9 +1384,13 @@ public final class URL implements java.io.Serializable {
|
|||
* Returns the protocol in lower case. Special cases known protocols
|
||||
* to avoid loading locale classes during startup.
|
||||
*/
|
||||
static String toLowerCase(String protocol) {
|
||||
if (protocol.equals("jrt") || protocol.equals("file") || protocol.equals("jar")) {
|
||||
return protocol;
|
||||
static String lowerCaseProtocol(String protocol) {
|
||||
if (protocol.equals("jrt")) {
|
||||
return "jrt";
|
||||
} else if (protocol.equals("file")) {
|
||||
return "file";
|
||||
} else if (protocol.equals("jar")) {
|
||||
return "jar";
|
||||
} else {
|
||||
return protocol.toLowerCase(Locale.ROOT);
|
||||
}
|
||||
|
|
|
@ -1092,7 +1092,7 @@ public abstract class URLConnection {
|
|||
* @since 9
|
||||
*/
|
||||
public static void setDefaultUseCaches(String protocol, boolean defaultVal) {
|
||||
protocol = protocol.toLowerCase(Locale.US);
|
||||
protocol = URL.lowerCaseProtocol(protocol);
|
||||
defaultCaching.put(protocol, defaultVal);
|
||||
}
|
||||
|
||||
|
@ -1108,7 +1108,7 @@ public abstract class URLConnection {
|
|||
* @since 9
|
||||
*/
|
||||
public static boolean getDefaultUseCaches(String protocol) {
|
||||
Boolean protoDefault = defaultCaching.get(protocol.toLowerCase(Locale.US));
|
||||
Boolean protoDefault = defaultCaching.get(URL.lowerCaseProtocol(protocol));
|
||||
if (protoDefault != null) {
|
||||
return protoDefault.booleanValue();
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue