< prev index next >

src/java.base/share/classes/java/net/SocketPermission.java

Print this page
rev 52881 : 8214971: Replace use of string.equals("") with isEmpty()
Reviewed-by: jlaskey, prappo, lancea, dfuchs, redestad

@@ -303,11 +303,11 @@
     private void setDeny() {
         defaultDeny = true;
     }
 
     private static String getHost(String host) {
-        if (host.equals("")) {
+        if (host.isEmpty()) {
             return "localhost";
         } else {
             /* IPv6 literal address used in this context should follow
              * the format specified in RFC 2732;
              * if not, we try to solve the unambiguous case

@@ -342,11 +342,11 @@
 
     private int[] parsePort(String port)
         throws Exception
     {
 
-        if (port == null || port.equals("") || port.equals("*")) {
+        if (port == null || port.isEmpty() || port.equals("*")) {
             return new int[] {PORT_MIN, PORT_MAX};
         }
 
         int dash = port.indexOf('-');
 

@@ -356,17 +356,17 @@
         } else {
             String low = port.substring(0, dash);
             String high = port.substring(dash+1);
             int l,h;
 
-            if (low.equals("")) {
+            if (low.isEmpty()) {
                 l = PORT_MIN;
             } else {
                 l = Integer.parseInt(low);
             }
 
-            if (high.equals("")) {
+            if (high.isEmpty()) {
                 h = PORT_MAX;
             } else {
                 h = Integer.parseInt(high);
             }
             if (l < 0 || h < 0 || h<l)

@@ -494,11 +494,11 @@
 
         if (action == null) {
             throw new NullPointerException("action can't be null");
         }
 
-        if (action.equals("")) {
+        if (action.isEmpty()) {
             throw new IllegalArgumentException("action can't be empty");
         }
 
         int mask = NONE;
 
< prev index next >