mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8274949: Use String.contains() instead of String.indexOf() in java.base
Reviewed-by: weijun, dfuchs, vtewari, lancea
This commit is contained in:
parent
09e8c8c64a
commit
6677554374
17 changed files with 35 additions and 38 deletions
|
@ -1078,13 +1078,13 @@ public final class HttpCookie implements Cloneable {
|
|||
int version = 0;
|
||||
|
||||
header = header.toLowerCase();
|
||||
if (header.indexOf("expires=") != -1) {
|
||||
if (header.contains("expires=")) {
|
||||
// only netscape cookie using 'expires'
|
||||
version = 0;
|
||||
} else if (header.indexOf("version=") != -1) {
|
||||
} else if (header.contains("version=")) {
|
||||
// version is mandatory for rfc 2965/2109 cookie
|
||||
version = 1;
|
||||
} else if (header.indexOf("max-age") != -1) {
|
||||
} else if (header.contains("max-age")) {
|
||||
// rfc 2965/2109 use 'max-age'
|
||||
version = 1;
|
||||
} else if (startsWithIgnoreCase(header, SET_COOKIE2)) {
|
||||
|
|
|
@ -600,7 +600,7 @@ public abstract class HttpURLConnection extends URLConnection {
|
|||
public long getHeaderFieldDate(String name, long Default) {
|
||||
String dateString = getHeaderField(name);
|
||||
try {
|
||||
if (dateString.indexOf("GMT") == -1) {
|
||||
if (!dateString.contains("GMT")) {
|
||||
dateString = dateString+" GMT";
|
||||
}
|
||||
return Date.parse(dateString);
|
||||
|
|
|
@ -30,12 +30,10 @@ import java.io.ObjectInputStream;
|
|||
import java.io.ObjectOutputStream;
|
||||
import java.io.ObjectStreamField;
|
||||
import java.io.Serializable;
|
||||
import java.net.InetAddress;
|
||||
import java.security.AccessController;
|
||||
import java.security.Permission;
|
||||
import java.security.PermissionCollection;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.security.Security;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Map;
|
||||
|
@ -333,7 +331,7 @@ public final class SocketPermission extends Permission
|
|||
ind = host.lastIndexOf(':');
|
||||
host = "[" + host.substring(0, ind) + "]" +
|
||||
host.substring(ind);
|
||||
} else if (tokens == 8 && host.indexOf("::") == -1) {
|
||||
} else if (tokens == 8 && !host.contains("::")) {
|
||||
// IPv6 address only, not followed by port
|
||||
host = "[" + host + "]";
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue