< prev index next >

src/java.base/share/classes/sun/security/ssl/X509TrustManagerImpl.java

Print this page
rev 51919 : 8215281: Use String.isEmpty() when applicable in java.base
Reviewed-by: dfuchs, alanb

@@ -146,11 +146,11 @@
         if (chain == null || chain.length == 0) {
             throw new IllegalArgumentException(
                 "null or zero-length certificate chain");
         }
 
-        if (authType == null || authType.length() == 0) {
+        if (authType == null || authType.isEmpty()) {
             throw new IllegalArgumentException(
                 "null or zero-length authentication type");
         }
 
         Validator v = null;

@@ -227,11 +227,11 @@
                     trustedChain[trustedChain.length-1]);
 
             // check endpoint identity
             String identityAlg = sslSocket.getSSLParameters().
                     getEndpointIdentificationAlgorithm();
-            if (identityAlg != null && identityAlg.length() != 0) {
+            if (identityAlg != null && !identityAlg.isEmpty()) {
                 checkIdentity(session, trustedChain[0], identityAlg, isClient,
                         getRequestedServerNames(socket), chainsToPublicCA);
             }
         } else {
             trustedChain = validate(v, chain, Collections.emptyList(),

@@ -285,11 +285,11 @@
                     trustedChain[trustedChain.length-1]);
 
             // check endpoint identity
             String identityAlg = engine.getSSLParameters().
                     getEndpointIdentificationAlgorithm();
-            if (identityAlg != null && identityAlg.length() != 0) {
+            if (identityAlg != null && !identityAlg.isEmpty()) {
                 checkIdentity(session, trustedChain[0], identityAlg, isClient,
                         getRequestedServerNames(engine), chainsToPublicCA);
             }
         } else {
             trustedChain = validate(v, chain, Collections.emptyList(),

@@ -446,11 +446,11 @@
     }
 
     private static void checkIdentity(String hostname, X509Certificate cert,
             String algorithm, boolean chainsToPublicCA)
             throws CertificateException {
-        if (algorithm != null && algorithm.length() != 0) {
+        if (algorithm != null && !algorithm.isEmpty()) {
             // if IPv6 strip off the "[]"
             if ((hostname != null) && hostname.startsWith("[") &&
                     hostname.endsWith("]")) {
                 hostname = hostname.substring(1, hostname.length() - 1);
             }
< prev index next >