< prev index next >

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

Print this page
rev 52979 : 8215281: Use String.isEmpty() when applicable in java.base
Reviewed-by: TBD

@@ -434,19 +434,19 @@
         if (SSLLogger.isOn && SSLLogger.isOn("ssl,sslctx")) {
             SSLLogger.fine(
                     "System property " + propertyName + " is set to '" +
                     property + "'");
         }
-        if (property != null && property.length() != 0) {
+        if (property != null && !property.isEmpty()) {
             // remove double quote marks from beginning/end of the property
             if (property.length() > 1 && property.charAt(0) == '"' &&
                     property.charAt(property.length() - 1) == '"') {
                 property = property.substring(1, property.length() - 1);
             }
         }
 
-        if (property != null && property.length() != 0) {
+        if (property != null && !property.isEmpty()) {
             String[] cipherSuiteNames = property.split(",");
             Collection<CipherSuite> cipherSuites =
                         new ArrayList<>(cipherSuiteNames.length);
             for (int i = 0; i < cipherSuiteNames.length; i++) {
                 cipherSuiteNames[i] = cipherSuiteNames[i].trim();

@@ -843,19 +843,19 @@
             String property = GetPropertyAction.privilegedGetProperty(propname);
             if (property == null) {
                 return;
             }
 
-            if (property.length() != 0) {
+            if (!property.isEmpty()) {
                 // remove double quote marks from beginning/end of the property
                 if (property.length() > 1 && property.charAt(0) == '"' &&
                         property.charAt(property.length() - 1) == '"') {
                     property = property.substring(1, property.length() - 1);
                 }
             }
 
-            if (property.length() != 0) {
+            if (!property.isEmpty()) {
                 String[] protocols = property.split(",");
                 for (int i = 0; i < protocols.length; i++) {
                     protocols[i] = protocols[i].trim();
                     // Is it a supported protocol name?
                     ProtocolVersion pv =

@@ -1107,11 +1107,11 @@
 
             FileInputStream fs = null;
             KeyStore ks = null;
             char[] passwd = null;
             try {
-                if (defaultKeyStore.length() != 0 &&
+                if (!defaultKeyStore.isEmpty() &&
                         !NONE.equals(defaultKeyStore)) {
                     fs = AccessController.doPrivileged(
                             new PrivilegedExceptionAction<FileInputStream>() {
                         @Override
                         public FileInputStream run() throws Exception {

@@ -1119,22 +1119,22 @@
                         }
                     });
                 }
 
                 String defaultKeyStorePassword = props.get("keyStorePasswd");
-                if (defaultKeyStorePassword.length() != 0) {
+                if (!defaultKeyStorePassword.isEmpty()) {
                     passwd = defaultKeyStorePassword.toCharArray();
                 }
 
                 /**
                  * Try to initialize key store.
                  */
                 if ((defaultKeyStoreType.length()) != 0) {
                     if (SSLLogger.isOn && SSLLogger.isOn("ssl,defaultctx")) {
                         SSLLogger.finest("init keystore");
                     }
-                    if (defaultKeyStoreProvider.length() == 0) {
+                    if (defaultKeyStoreProvider.isEmpty()) {
                         ks = KeyStore.getInstance(defaultKeyStoreType);
                     } else {
                         ks = KeyStore.getInstance(defaultKeyStoreType,
                                             defaultKeyStoreProvider);
                     }

@@ -1559,11 +1559,11 @@
             }
 
             // check endpoint identity
             String identityAlg = sslSocket.getSSLParameters().
                                         getEndpointIdentificationAlgorithm();
-            if (identityAlg != null && identityAlg.length() != 0) {
+            if (identityAlg != null && !identityAlg.isEmpty()) {
                 String hostname = session.getPeerHost();
                 X509TrustManagerImpl.checkIdentity(
                                     hostname, chain[0], identityAlg);
             }
 

@@ -1599,11 +1599,11 @@
             }
 
             // check endpoint identity
             String identityAlg = engine.getSSLParameters().
                                         getEndpointIdentificationAlgorithm();
-            if (identityAlg != null && identityAlg.length() != 0) {
+            if (identityAlg != null && !identityAlg.isEmpty()) {
                 String hostname = session.getPeerHost();
                 X509TrustManagerImpl.checkIdentity(
                                     hostname, chain[0], identityAlg);
             }
 
< prev index next >