< prev index next >
src/java.base/share/classes/java/security/Security.java
Print this page
rev 51919 : 8215281: Use String.isEmpty() when applicable in java.base
Reviewed-by: dfuchs, alanb
*** 645,655 ****
candidates = null;
break;
}
}
! if ((candidates == null) || (candidates.isEmpty()))
return null;
Object[] candidatesArray = candidates.toArray();
Provider[] result = new Provider[candidatesArray.length];
--- 645,655 ----
candidates = null;
break;
}
}
! if (candidates == null || candidates.isEmpty())
return null;
Object[] candidatesArray = candidates.toArray();
Provider[] result = new Provider[candidatesArray.length];
*** 991,1005 ****
String serviceName = filterKey.substring(0, algIndex);
String algName = null;
String attrName = null;
! if (filterValue.length() == 0) {
// The filterValue is an empty string. So the filterKey
// should be in the format of <crypto_service>.<algorithm_or_type>.
algName = filterKey.substring(algIndex + 1).trim();
! if (algName.length() == 0) {
// There must be a algorithm or type name.
throw new InvalidParameterException("Invalid filter");
}
} else {
// The filterValue is a non-empty string. So the filterKey must be
--- 991,1005 ----
String serviceName = filterKey.substring(0, algIndex);
String algName = null;
String attrName = null;
! if (filterValue.isEmpty()) {
// The filterValue is an empty string. So the filterKey
// should be in the format of <crypto_service>.<algorithm_or_type>.
algName = filterKey.substring(algIndex + 1).trim();
! if (algName.isEmpty()) {
// There must be a algorithm or type name.
throw new InvalidParameterException("Invalid filter");
}
} else {
// The filterValue is a non-empty string. So the filterKey must be
*** 1010,1020 ****
if (attrIndex == -1) {
// There is no attribute name in the filter.
throw new InvalidParameterException("Invalid filter");
} else {
attrName = filterKey.substring(attrIndex + 1).trim();
! if (attrName.length() == 0) {
// There is no attribute name in the filter.
throw new InvalidParameterException("Invalid filter");
}
}
--- 1010,1020 ----
if (attrIndex == -1) {
// There is no attribute name in the filter.
throw new InvalidParameterException("Invalid filter");
} else {
attrName = filterKey.substring(attrIndex + 1).trim();
! if (attrName.isEmpty()) {
// There is no attribute name in the filter.
throw new InvalidParameterException("Invalid filter");
}
}
*** 1056,1066 ****
*
* @since 1.4
**/
public static Set<String> getAlgorithms(String serviceName) {
! if ((serviceName == null) || (serviceName.length() == 0) ||
(serviceName.endsWith("."))) {
return Collections.emptySet();
}
HashSet<String> result = new HashSet<>();
--- 1056,1066 ----
*
* @since 1.4
**/
public static Set<String> getAlgorithms(String serviceName) {
! if ((serviceName == null) || (serviceName.isEmpty()) ||
(serviceName.endsWith("."))) {
return Collections.emptySet();
}
HashSet<String> result = new HashSet<>();
< prev index next >