-
Enhancement
-
Resolution: Fixed
-
P5
-
None
-
b03
There is a field 'Map<String, DomainEntry> domainEntries' in sun.security.provider.PolicyParser class. It's filled in 'read' method with non-null values only. In read method there is redundant 'containsKey' check:
if (!domainEntries.containsKey(domainName)) {
domainEntries.put(domainName, de);
} else {
LocalizedMessage localizedMsg = new LocalizedMessage(
"duplicate.keystore.domain.name");
Object[] source = {domainName};
String msg = "duplicate keystore domain name: " +
domainName;
throw new ParsingException(msg, localizedMsg, source);
}
Instead of pair TreeMap.containsKey/TreeMap.put method calls, we can use single call TreeMap.putIfAbsent and check result for nullness.
if (!domainEntries.containsKey(domainName)) {
domainEntries.put(domainName, de);
} else {
LocalizedMessage localizedMsg = new LocalizedMessage(
"duplicate.keystore.domain.name");
Object[] source = {domainName};
String msg = "duplicate keystore domain name: " +
domainName;
throw new ParsingException(msg, localizedMsg, source);
}
Instead of pair TreeMap.containsKey/TreeMap.put method calls, we can use single call TreeMap.putIfAbsent and check result for nullness.