mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
8215281: Use String.isEmpty() when applicable in java.base
Reviewed-by: dfuchs, alanb
This commit is contained in:
parent
c998ead188
commit
a3df1d618e
155 changed files with 340 additions and 382 deletions
|
@ -228,7 +228,7 @@ public class AlgorithmParameterGenerator {
|
|||
throws NoSuchAlgorithmException, NoSuchProviderException
|
||||
{
|
||||
Objects.requireNonNull(algorithm, "null algorithm name");
|
||||
if (provider == null || provider.length() == 0)
|
||||
if (provider == null || provider.isEmpty())
|
||||
throw new IllegalArgumentException("missing provider");
|
||||
Object[] objs = Security.getImpl(algorithm,
|
||||
"AlgorithmParameterGenerator",
|
||||
|
|
|
@ -209,7 +209,7 @@ public class AlgorithmParameters {
|
|||
throws NoSuchAlgorithmException, NoSuchProviderException
|
||||
{
|
||||
Objects.requireNonNull(algorithm, "null algorithm name");
|
||||
if (provider == null || provider.length() == 0)
|
||||
if (provider == null || provider.isEmpty())
|
||||
throw new IllegalArgumentException("missing provider");
|
||||
Object[] objs = Security.getImpl(algorithm, "AlgorithmParameters",
|
||||
provider);
|
||||
|
|
|
@ -913,7 +913,7 @@ public class KeyStore {
|
|||
throws KeyStoreException, NoSuchProviderException
|
||||
{
|
||||
Objects.requireNonNull(type, "null type name");
|
||||
if (provider == null || provider.length() == 0)
|
||||
if (provider == null || provider.isEmpty())
|
||||
throw new IllegalArgumentException("missing provider");
|
||||
try {
|
||||
Object[] objs = Security.getImpl(type, "KeyStore", provider);
|
||||
|
|
|
@ -237,7 +237,7 @@ public abstract class MessageDigest extends MessageDigestSpi {
|
|||
throws NoSuchAlgorithmException, NoSuchProviderException
|
||||
{
|
||||
Objects.requireNonNull(algorithm, "null algorithm name");
|
||||
if (provider == null || provider.length() == 0)
|
||||
if (provider == null || provider.isEmpty())
|
||||
throw new IllegalArgumentException("missing provider");
|
||||
Object[] objs = Security.getImpl(algorithm, "MessageDigest", provider);
|
||||
if (objs[0] instanceof MessageDigest) {
|
||||
|
|
|
@ -222,7 +222,7 @@ public abstract class Permission implements Guard, java.io.Serializable {
|
|||
*/
|
||||
public String toString() {
|
||||
String actions = getActions();
|
||||
if ((actions == null) || (actions.length() == 0)) { // OPTIONAL
|
||||
if (actions == null || actions.isEmpty()) { // OPTIONAL
|
||||
return "(\"" + getClass().getName() + "\" \"" + name + "\")";
|
||||
} else {
|
||||
return "(\"" + getClass().getName() + "\" \"" + name +
|
||||
|
|
|
@ -456,7 +456,7 @@ public abstract class Policy {
|
|||
throws NoSuchProviderException, NoSuchAlgorithmException {
|
||||
|
||||
Objects.requireNonNull(type, "null type name");
|
||||
if (provider == null || provider.length() == 0) {
|
||||
if (provider == null || provider.isEmpty()) {
|
||||
throw new IllegalArgumentException("missing provider");
|
||||
}
|
||||
|
||||
|
|
|
@ -942,7 +942,7 @@ public class SecureRandom extends java.util.Random {
|
|||
}
|
||||
});
|
||||
|
||||
if ((property == null) || (property.length() == 0)) {
|
||||
if (property == null || property.isEmpty()) {
|
||||
throw new NoSuchAlgorithmException(
|
||||
"Null/empty securerandom.strongAlgorithms Security Property");
|
||||
}
|
||||
|
|
|
@ -649,7 +649,7 @@ public final class Security {
|
|||
}
|
||||
}
|
||||
|
||||
if ((candidates == null) || (candidates.isEmpty()))
|
||||
if (candidates == null || candidates.isEmpty())
|
||||
return null;
|
||||
|
||||
Object[] candidatesArray = candidates.toArray();
|
||||
|
@ -1005,11 +1005,11 @@ public final class Security {
|
|||
String algName = null;
|
||||
String attrName = null;
|
||||
|
||||
if (filterValue.length() == 0) {
|
||||
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.length() == 0) {
|
||||
if (algName.isEmpty()) {
|
||||
// There must be a algorithm or type name.
|
||||
throw new InvalidParameterException("Invalid filter");
|
||||
}
|
||||
|
@ -1024,7 +1024,7 @@ public final class Security {
|
|||
throw new InvalidParameterException("Invalid filter");
|
||||
} else {
|
||||
attrName = filterKey.substring(attrIndex + 1).trim();
|
||||
if (attrName.length() == 0) {
|
||||
if (attrName.isEmpty()) {
|
||||
// There is no attribute name in the filter.
|
||||
throw new InvalidParameterException("Invalid filter");
|
||||
}
|
||||
|
@ -1070,7 +1070,7 @@ public final class Security {
|
|||
**/
|
||||
public static Set<String> getAlgorithms(String serviceName) {
|
||||
|
||||
if ((serviceName == null) || (serviceName.length() == 0) ||
|
||||
if ((serviceName == null) || (serviceName.isEmpty()) ||
|
||||
(serviceName.endsWith("."))) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
|
|
@ -360,7 +360,7 @@ public abstract class Signature extends SignatureSpi {
|
|||
Objects.requireNonNull(algorithm, "null algorithm name");
|
||||
if (algorithm.equalsIgnoreCase(RSA_SIGNATURE)) {
|
||||
// exception compatibility with existing code
|
||||
if ((provider == null) || (provider.length() == 0)) {
|
||||
if (provider == null || provider.isEmpty()) {
|
||||
throw new IllegalArgumentException("missing provider");
|
||||
}
|
||||
Provider p = Security.getProvider(provider);
|
||||
|
|
|
@ -210,7 +210,7 @@ public class TrustAnchor {
|
|||
if (caName == null)
|
||||
throw new NullPointerException("the caName parameter must be " +
|
||||
"non-null");
|
||||
if (caName.length() == 0)
|
||||
if (caName.isEmpty())
|
||||
throw new IllegalArgumentException("the caName " +
|
||||
"parameter must be a non-empty String");
|
||||
// check if caName is formatted correctly
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue