< 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,313 ****
private void setDeny() {
defaultDeny = true;
}
private static String getHost(String host) {
! if (host.equals("")) {
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
--- 303,313 ----
private void setDeny() {
defaultDeny = true;
}
private static String getHost(String host) {
! 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,352 ****
private int[] parsePort(String port)
throws Exception
{
! if (port == null || port.equals("") || port.equals("*")) {
return new int[] {PORT_MIN, PORT_MAX};
}
int dash = port.indexOf('-');
--- 342,352 ----
private int[] parsePort(String port)
throws Exception
{
! if (port == null || port.isEmpty() || port.equals("*")) {
return new int[] {PORT_MIN, PORT_MAX};
}
int dash = port.indexOf('-');
*** 356,372 ****
} else {
String low = port.substring(0, dash);
String high = port.substring(dash+1);
int l,h;
! if (low.equals("")) {
l = PORT_MIN;
} else {
l = Integer.parseInt(low);
}
! if (high.equals("")) {
h = PORT_MAX;
} else {
h = Integer.parseInt(high);
}
if (l < 0 || h < 0 || h<l)
--- 356,372 ----
} else {
String low = port.substring(0, dash);
String high = port.substring(dash+1);
int l,h;
! if (low.isEmpty()) {
l = PORT_MIN;
} else {
l = Integer.parseInt(low);
}
! if (high.isEmpty()) {
h = PORT_MAX;
} else {
h = Integer.parseInt(high);
}
if (l < 0 || h < 0 || h<l)
*** 494,504 ****
if (action == null) {
throw new NullPointerException("action can't be null");
}
! if (action.equals("")) {
throw new IllegalArgumentException("action can't be empty");
}
int mask = NONE;
--- 494,504 ----
if (action == null) {
throw new NullPointerException("action can't be null");
}
! if (action.isEmpty()) {
throw new IllegalArgumentException("action can't be empty");
}
int mask = NONE;
< prev index next >