8311943: Cleanup usages of toLowerCase() and toUpperCase() in java.base
Reviewed-by: naoto
This commit is contained in:
parent
13f6450e2e
commit
b32d6411c4
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -181,7 +181,7 @@ public final class KeychainStore extends KeyStoreSpi {
|
||||
password = Long.toString(random.nextLong()).toCharArray();
|
||||
}
|
||||
|
||||
Object entry = entries.get(alias.toLowerCase());
|
||||
Object entry = entries.get(alias.toLowerCase(Locale.ROOT));
|
||||
|
||||
if (!(entry instanceof KeyEntry keyEntry)) {
|
||||
return null;
|
||||
@ -271,7 +271,7 @@ public final class KeychainStore extends KeyStoreSpi {
|
||||
public Certificate[] engineGetCertificateChain(String alias) {
|
||||
permissionCheck();
|
||||
|
||||
Object entry = entries.get(alias.toLowerCase());
|
||||
Object entry = entries.get(alias.toLowerCase(Locale.ROOT));
|
||||
|
||||
if (entry instanceof KeyEntry keyEntry) {
|
||||
if (keyEntry.chain == null) {
|
||||
@ -302,7 +302,7 @@ public final class KeychainStore extends KeyStoreSpi {
|
||||
public Certificate engineGetCertificate(String alias) {
|
||||
permissionCheck();
|
||||
|
||||
Object entry = entries.get(alias.toLowerCase());
|
||||
Object entry = entries.get(alias.toLowerCase(Locale.ROOT));
|
||||
|
||||
if (entry != null) {
|
||||
if (entry instanceof TrustedCertEntry) {
|
||||
@ -337,7 +337,7 @@ public final class KeychainStore extends KeyStoreSpi {
|
||||
public KeyStore.Entry engineGetEntry(String alias, KeyStore.ProtectionParameter protParam)
|
||||
throws KeyStoreException, NoSuchAlgorithmException, UnrecoverableEntryException {
|
||||
if (engineIsCertificateEntry(alias)) {
|
||||
Object entry = entries.get(alias.toLowerCase());
|
||||
Object entry = entries.get(alias.toLowerCase(Locale.ROOT));
|
||||
if (entry instanceof TrustedCertEntry tEntry) {
|
||||
return new KeyStore.TrustedCertificateEntry(
|
||||
tEntry.cert, Set.of(
|
||||
@ -359,7 +359,7 @@ public final class KeychainStore extends KeyStoreSpi {
|
||||
public Date engineGetCreationDate(String alias) {
|
||||
permissionCheck();
|
||||
|
||||
Object entry = entries.get(alias.toLowerCase());
|
||||
Object entry = entries.get(alias.toLowerCase(Locale.ROOT));
|
||||
|
||||
if (entry != null) {
|
||||
if (entry instanceof TrustedCertEntry) {
|
||||
@ -427,7 +427,7 @@ public final class KeychainStore extends KeyStoreSpi {
|
||||
entry.chainRefs = new long[entry.chain.length];
|
||||
}
|
||||
|
||||
String lowerAlias = alias.toLowerCase();
|
||||
String lowerAlias = alias.toLowerCase(Locale.ROOT);
|
||||
if (entries.get(lowerAlias) != null) {
|
||||
deletedEntries.put(lowerAlias, entries.get(lowerAlias));
|
||||
}
|
||||
@ -491,7 +491,7 @@ public final class KeychainStore extends KeyStoreSpi {
|
||||
entry.chainRefs = new long[entry.chain.length];
|
||||
}
|
||||
|
||||
String lowerAlias = alias.toLowerCase();
|
||||
String lowerAlias = alias.toLowerCase(Locale.ROOT);
|
||||
if (entries.get(lowerAlias) != null) {
|
||||
deletedEntries.put(lowerAlias, entries.get(alias));
|
||||
}
|
||||
@ -521,9 +521,10 @@ public final class KeychainStore extends KeyStoreSpi {
|
||||
{
|
||||
permissionCheck();
|
||||
|
||||
String lowerAlias = alias.toLowerCase(Locale.ROOT);
|
||||
synchronized(entries) {
|
||||
Object entry = entries.remove(alias.toLowerCase());
|
||||
deletedEntries.put(alias.toLowerCase(), entry);
|
||||
Object entry = entries.remove(lowerAlias);
|
||||
deletedEntries.put(lowerAlias, entry);
|
||||
}
|
||||
}
|
||||
|
||||
@ -546,7 +547,7 @@ public final class KeychainStore extends KeyStoreSpi {
|
||||
*/
|
||||
public boolean engineContainsAlias(String alias) {
|
||||
permissionCheck();
|
||||
return entries.containsKey(alias.toLowerCase());
|
||||
return entries.containsKey(alias.toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -568,7 +569,7 @@ public final class KeychainStore extends KeyStoreSpi {
|
||||
*/
|
||||
public boolean engineIsKeyEntry(String alias) {
|
||||
permissionCheck();
|
||||
Object entry = entries.get(alias.toLowerCase());
|
||||
Object entry = entries.get(alias.toLowerCase(Locale.ROOT));
|
||||
return entry instanceof KeyEntry;
|
||||
}
|
||||
|
||||
@ -581,7 +582,7 @@ public final class KeychainStore extends KeyStoreSpi {
|
||||
*/
|
||||
public boolean engineIsCertificateEntry(String alias) {
|
||||
permissionCheck();
|
||||
Object entry = entries.get(alias.toLowerCase());
|
||||
Object entry = entries.get(alias.toLowerCase(Locale.ROOT));
|
||||
return entry instanceof TrustedCertEntry;
|
||||
}
|
||||
|
||||
@ -806,10 +807,10 @@ public final class KeychainStore extends KeyStoreSpi {
|
||||
// Check whether a certificate with same alias already exists and is the same
|
||||
// If yes, we can return here - the existing entry must have the same
|
||||
// properties and trust settings
|
||||
if (entries.contains(alias.toLowerCase())) {
|
||||
if (entries.contains(alias.toLowerCase(Locale.ROOT))) {
|
||||
int uniqueVal = 1;
|
||||
String originalAlias = alias;
|
||||
var co = entries.get(alias.toLowerCase());
|
||||
var co = entries.get(alias.toLowerCase(Locale.ROOT));
|
||||
while (co != null) {
|
||||
if (co instanceof TrustedCertEntry tco) {
|
||||
if (tco.cert.equals(tce.cert)) {
|
||||
@ -817,7 +818,7 @@ public final class KeychainStore extends KeyStoreSpi {
|
||||
}
|
||||
}
|
||||
alias = originalAlias + " " + uniqueVal++;
|
||||
co = entries.get(alias.toLowerCase());
|
||||
co = entries.get(alias.toLowerCase(Locale.ROOT));
|
||||
}
|
||||
}
|
||||
|
||||
@ -900,7 +901,7 @@ public final class KeychainStore extends KeyStoreSpi {
|
||||
else
|
||||
tce.date = new Date();
|
||||
|
||||
entries.put(alias.toLowerCase(), tce);
|
||||
entries.put(alias.toLowerCase(Locale.ROOT), tce);
|
||||
} catch (Exception e) {
|
||||
// The certificate will be skipped.
|
||||
System.err.println("KeychainStore Ignored Exception: " + e);
|
||||
@ -971,12 +972,12 @@ public final class KeychainStore extends KeyStoreSpi {
|
||||
int uniqueVal = 1;
|
||||
String originalAlias = alias;
|
||||
|
||||
while (entries.containsKey(alias.toLowerCase())) {
|
||||
while (entries.containsKey(alias.toLowerCase(Locale.ROOT))) {
|
||||
alias = originalAlias + " " + uniqueVal;
|
||||
uniqueVal++;
|
||||
}
|
||||
|
||||
entries.put(alias.toLowerCase(), ke);
|
||||
entries.put(alias.toLowerCase(Locale.ROOT), ke);
|
||||
}
|
||||
|
||||
private static class CertKeychainItemPair {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -27,6 +27,8 @@ package java.net;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import sun.security.util.SecurityConstants;
|
||||
|
||||
/**
|
||||
@ -210,7 +212,7 @@ public abstract class ProxySelector {
|
||||
|
||||
@Override
|
||||
public synchronized List<Proxy> select(URI uri) {
|
||||
String scheme = uri.getScheme().toLowerCase();
|
||||
String scheme = uri.getScheme().toLowerCase(Locale.ROOT);
|
||||
if (scheme.equals("http") || scheme.equals("https")) {
|
||||
return list;
|
||||
} else {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -817,7 +817,7 @@ public class KeyStore {
|
||||
this.type = type;
|
||||
|
||||
if (!skipDebug && pdebug != null) {
|
||||
pdebug.println("KeyStore." + type.toUpperCase() + " type from: " +
|
||||
pdebug.println("KeyStore." + type.toUpperCase(Locale.ROOT) + " type from: " +
|
||||
getProviderName());
|
||||
}
|
||||
}
|
||||
|
@ -4725,7 +4725,7 @@ public final class DateTimeFormatterBuilder {
|
||||
* @return the position after the parse
|
||||
*/
|
||||
private int parseOffsetBased(DateTimeParseContext context, CharSequence text, int prefixPos, int position, OffsetIdPrinterParser parser) {
|
||||
String prefix = text.subSequence(prefixPos, position).toString().toUpperCase();
|
||||
String prefix = text.subSequence(prefixPos, position).toString().toUpperCase(Locale.ROOT);
|
||||
if (position >= text.length()) {
|
||||
context.setParsed(ZoneId.of(prefix));
|
||||
return position;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -32,6 +32,7 @@ import java.io.Reader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import jdk.internal.org.xml.sax.InputSource;
|
||||
import jdk.internal.org.xml.sax.SAXException;
|
||||
@ -1601,7 +1602,7 @@ public abstract class Parser {
|
||||
// PI target name may not be empty string [#2.6]
|
||||
// PI target name 'XML' is reserved [#2.6]
|
||||
if ((str.isEmpty())
|
||||
|| (mXml.name.equals(str.toLowerCase()) == true)) {
|
||||
|| (mXml.name.equals(str.toLowerCase(Locale.ROOT)) == true)) {
|
||||
panic(FAULT);
|
||||
}
|
||||
// This is processing instruction
|
||||
@ -2858,7 +2859,7 @@ public abstract class Parser {
|
||||
String expenc;
|
||||
if (is.getEncoding() != null) {
|
||||
// Ignore encoding in the xml text decl.
|
||||
expenc = is.getEncoding().toUpperCase();
|
||||
expenc = is.getEncoding().toUpperCase(Locale.ROOT);
|
||||
if (expenc.equals("UTF-16")) {
|
||||
reader = bom(is.getByteStream(), 'U'); // UTF-16 [#4.3.3]
|
||||
} else {
|
||||
@ -3156,7 +3157,7 @@ public abstract class Parser {
|
||||
case 'A':
|
||||
case '_':
|
||||
bkch();
|
||||
str = name(false).toLowerCase();
|
||||
str = name(false).toLowerCase(Locale.ROOT);
|
||||
if ("version".equals(str) == true) {
|
||||
if (st != 1) {
|
||||
panic(FAULT);
|
||||
@ -3170,7 +3171,7 @@ public abstract class Parser {
|
||||
if (st != 2) {
|
||||
panic(FAULT);
|
||||
}
|
||||
mInp.xmlenc = eqstr('=').toUpperCase();
|
||||
mInp.xmlenc = eqstr('=').toUpperCase(Locale.ROOT);
|
||||
enc = mInp.xmlenc;
|
||||
st = 3;
|
||||
} else if ("standalone".equals(str) == true) {
|
||||
@ -3178,7 +3179,7 @@ public abstract class Parser {
|
||||
{
|
||||
panic(FAULT);
|
||||
}
|
||||
str = eqstr('=').toLowerCase();
|
||||
str = eqstr('=').toLowerCase(Locale.ROOT);
|
||||
// Check the 'standalone' value and use it [#5.1]
|
||||
if (str.equals("yes") == true) {
|
||||
mIsSAlone = true;
|
||||
|
@ -1315,7 +1315,7 @@ public final class LauncherHelper {
|
||||
}
|
||||
|
||||
private static <T> Stream<String> toStringStream(Set<T> s) {
|
||||
return s.stream().map(e -> e.toString().toLowerCase());
|
||||
return s.stream().map(e -> e.toString().toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
private static boolean isJrt(ModuleReference mref) {
|
||||
|
@ -377,7 +377,7 @@ public class DefaultProxySelector extends ProxySelector {
|
||||
if (disjunct.isEmpty())
|
||||
continue;
|
||||
disjunctionEmpty = false;
|
||||
String regex = disjunctToRegex(disjunct.toLowerCase());
|
||||
String regex = disjunctToRegex(disjunct.toLowerCase(Locale.ROOT));
|
||||
joiner.add(regex);
|
||||
}
|
||||
return disjunctionEmpty ? null : Pattern.compile(joiner.toString());
|
||||
|
@ -34,6 +34,7 @@ import java.net.UnknownHostException;
|
||||
import java.net.URL;
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.util.Base64;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.Properties;
|
||||
|
||||
@ -149,7 +150,7 @@ public class NTLMAuthentication extends AuthenticationInfo {
|
||||
username = s;
|
||||
ntdomain = defaultDomain;
|
||||
} else {
|
||||
ntdomain = s.substring (0, i).toUpperCase();
|
||||
ntdomain = s.substring (0, i).toUpperCase(Locale.ROOT);
|
||||
username = s.substring (i+1);
|
||||
}
|
||||
password = pw.getPassword();
|
||||
|
@ -288,7 +288,7 @@ abstract class UnixFileStore
|
||||
if (value != null) {
|
||||
String[] values = value.split("\\s");
|
||||
for (String s: values) {
|
||||
s = s.trim().toLowerCase();
|
||||
s = s.trim().toLowerCase(Locale.ROOT);
|
||||
if (s.equals(feature)) {
|
||||
return FeatureStatus.PRESENT;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1995, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1995, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -393,7 +393,7 @@ final class ProcessImpl extends Process {
|
||||
|
||||
// Old version that can be bypassed
|
||||
private boolean isShellFile(String executablePath) {
|
||||
String upPath = executablePath.toUpperCase();
|
||||
String upPath = executablePath.toUpperCase(Locale.ROOT);
|
||||
return (upPath.endsWith(".CMD") || upPath.endsWith(".BAT"));
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,7 @@ import java.net.InetAddress;
|
||||
import java.net.PasswordAuthentication;
|
||||
import java.net.UnknownHostException;
|
||||
import java.net.URL;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.Properties;
|
||||
import sun.net.NetProperties;
|
||||
@ -95,7 +96,7 @@ public class NTLMAuthentication extends AuthenticationInfo {
|
||||
public String run() {
|
||||
String localhost;
|
||||
try {
|
||||
localhost = InetAddress.getLocalHost().getHostName().toUpperCase();
|
||||
localhost = InetAddress.getLocalHost().getHostName().toUpperCase(Locale.ROOT);
|
||||
} catch (UnknownHostException e) {
|
||||
localhost = "localhost";
|
||||
}
|
||||
@ -136,7 +137,7 @@ public class NTLMAuthentication extends AuthenticationInfo {
|
||||
username = s;
|
||||
ntdomain = defaultDomain;
|
||||
} else {
|
||||
ntdomain = s.substring (0, i).toUpperCase();
|
||||
ntdomain = s.substring (0, i).toUpperCase(Locale.ROOT);
|
||||
username = s.substring (i+1);
|
||||
}
|
||||
password = new String (pw.getPassword());
|
||||
|
Loading…
x
Reference in New Issue
Block a user