< prev index next >

src/java.base/share/classes/sun/net/spi/DefaultProxySelector.java

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


 221             new PrivilegedAction<Proxy[]>() {
 222                 public Proxy[] run() {
 223                     int i, j;
 224                     String phost =  null;
 225                     int pport = 0;
 226                     String nphosts =  null;
 227                     InetSocketAddress saddr = null;
 228 
 229                     // Then let's walk the list of protocols in our array
 230                     for (i=0; i<props.length; i++) {
 231                         if (props[i][0].equalsIgnoreCase(proto)) {
 232                             for (j = 1; j < props[i].length; j++) {
 233                                 /* System.getProp() will give us an empty
 234                                  * String, "" for a defined but "empty"
 235                                  * property.
 236                                  */
 237                                 phost =  NetProperties.get(props[i][j]+"Host");
 238                                 if (phost != null && phost.length() != 0)
 239                                     break;
 240                             }
 241                             if (phost == null || phost.length() == 0) {
 242                                 /**
 243                                  * No system property defined for that
 244                                  * protocol. Let's check System Proxy
 245                                  * settings (Gnome, MacOsX & Windows) if
 246                                  * we were instructed to.
 247                                  */
 248                                 if (hasSystemProxies) {
 249                                     String sproto;
 250                                     if (proto.equalsIgnoreCase("socket"))
 251                                         sproto = "socks";
 252                                     else
 253                                         sproto = proto;
 254                                     return getSystemProxies(sproto, urlhost);
 255                                 }
 256                                 return null;
 257                             }
 258                             // If a Proxy Host is defined for that protocol
 259                             // Let's get the NonProxyHosts property
 260                             if (nprop != null) {
 261                                 nphosts = NetProperties.get(nprop.property);
 262                                 synchronized (nprop) {
 263                                     if (nphosts == null) {
 264                                         if (nprop.defaultVal != null) {
 265                                             nphosts = nprop.defaultVal;
 266                                         } else {
 267                                             nprop.hostsSource = null;
 268                                             nprop.pattern = null;
 269                                         }
 270                                     } else if (nphosts.length() != 0) {
 271                                         // add the required default patterns
 272                                         // but only if property no set. If it
 273                                         // is empty, leave empty.
 274                                         nphosts += "|" + NonProxyInfo
 275                                                          .defStringVal;
 276                                     }
 277                                     if (nphosts != null) {
 278                                         if (!nphosts.equals(nprop.hostsSource)) {
 279                                             nprop.pattern = toPattern(nphosts);
 280                                             nprop.hostsSource = nphosts;
 281                                         }
 282                                     }
 283                                     if (shouldNotUseProxyFor(nprop.pattern, urlhost)) {
 284                                         return null;
 285                                     }
 286                                 }
 287                             }
 288                             // We got a host, let's check for port
 289 
 290                             pport = NetProperties.getInteger(props[i][j]+"Port", 0).intValue();




 221             new PrivilegedAction<Proxy[]>() {
 222                 public Proxy[] run() {
 223                     int i, j;
 224                     String phost =  null;
 225                     int pport = 0;
 226                     String nphosts =  null;
 227                     InetSocketAddress saddr = null;
 228 
 229                     // Then let's walk the list of protocols in our array
 230                     for (i=0; i<props.length; i++) {
 231                         if (props[i][0].equalsIgnoreCase(proto)) {
 232                             for (j = 1; j < props[i].length; j++) {
 233                                 /* System.getProp() will give us an empty
 234                                  * String, "" for a defined but "empty"
 235                                  * property.
 236                                  */
 237                                 phost =  NetProperties.get(props[i][j]+"Host");
 238                                 if (phost != null && phost.length() != 0)
 239                                     break;
 240                             }
 241                             if (phost == null || phost.isEmpty()) {
 242                                 /**
 243                                  * No system property defined for that
 244                                  * protocol. Let's check System Proxy
 245                                  * settings (Gnome, MacOsX & Windows) if
 246                                  * we were instructed to.
 247                                  */
 248                                 if (hasSystemProxies) {
 249                                     String sproto;
 250                                     if (proto.equalsIgnoreCase("socket"))
 251                                         sproto = "socks";
 252                                     else
 253                                         sproto = proto;
 254                                     return getSystemProxies(sproto, urlhost);
 255                                 }
 256                                 return null;
 257                             }
 258                             // If a Proxy Host is defined for that protocol
 259                             // Let's get the NonProxyHosts property
 260                             if (nprop != null) {
 261                                 nphosts = NetProperties.get(nprop.property);
 262                                 synchronized (nprop) {
 263                                     if (nphosts == null) {
 264                                         if (nprop.defaultVal != null) {
 265                                             nphosts = nprop.defaultVal;
 266                                         } else {
 267                                             nprop.hostsSource = null;
 268                                             nprop.pattern = null;
 269                                         }
 270                                     } else if (!nphosts.isEmpty()) {
 271                                         // add the required default patterns
 272                                         // but only if property no set. If it
 273                                         // is empty, leave empty.
 274                                         nphosts += "|" + NonProxyInfo
 275                                                          .defStringVal;
 276                                     }
 277                                     if (nphosts != null) {
 278                                         if (!nphosts.equals(nprop.hostsSource)) {
 279                                             nprop.pattern = toPattern(nphosts);
 280                                             nprop.hostsSource = nphosts;
 281                                         }
 282                                     }
 283                                     if (shouldNotUseProxyFor(nprop.pattern, urlhost)) {
 284                                         return null;
 285                                     }
 286                                 }
 287                             }
 288                             // We got a host, let's check for port
 289 
 290                             pport = NetProperties.getInteger(props[i][j]+"Port", 0).intValue();


< prev index next >