8287497: Use String.contains() instead of String.indexOf() in java.naming

Reviewed-by: aefimov, rriggs, jpai
This commit is contained in:
Andrey Turbanov 2022-05-31 06:59:03 +00:00
parent b2ba9fc9f6
commit 8a9aeff18c
4 changed files with 13 additions and 13 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -157,7 +157,7 @@ final class LdapAttribute extends BasicAttribute {
// remove any security credentials - otherwise the serialized form
// would store them in the clear
for (String key : realEnv.keySet()){
if (key.indexOf("security") != -1 ) {
if (key.contains("security")) {
//if we need to remove props, we must do it to a clone
//of the environment. cloning is expensive, so we only do

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -759,9 +759,9 @@ public final class LdapClient implements PooledConnection {
Hashtable<String, Boolean> binaryAttrs) {
String id = attrid.toLowerCase(Locale.ENGLISH);
return ((id.indexOf(";binary") != -1) ||
return id.contains(";binary") ||
defaultBinaryAttrs.containsKey(id) ||
((binaryAttrs != null) && (binaryAttrs.containsKey(id))));
((binaryAttrs != null) && (binaryAttrs.containsKey(id)));
}
// package entry point; used by Connection

View File

@ -426,7 +426,7 @@ public final class StartTlsResponseImpl extends StartTlsResponse {
* hostname verification is not done for anonymous ciphers
*/
String cipher = session.getCipherSuite();
if (cipher != null && (cipher.indexOf("_anon_") != -1)) {
if (cipher != null && cipher.contains("_anon_")) {
return true;
}
throw e;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -95,7 +95,7 @@ class NameImpl {
} else if (isA(name, i, syntaxSeparator2)) {
i += syntaxSeparator2.length();
}
return (i);
return i;
}
private final int extractComp(String name, int i, int len, Vector<String> comps)
@ -346,7 +346,7 @@ class NameImpl {
// determine whether there are any separators; if so escape
// or quote them
if (syntaxSeparator != null &&
comp.indexOf(syntaxSeparator) >= 0) {
comp.contains(syntaxSeparator)) {
if (syntaxBeginQuote1 != null) {
beginQuote = syntaxBeginQuote1;
endQuote = syntaxEndQuote1;
@ -357,7 +357,7 @@ class NameImpl {
escapeSeparator = true;
}
if (syntaxSeparator2 != null &&
comp.indexOf(syntaxSeparator2) >= 0) {
comp.contains(syntaxSeparator2)) {
if (syntaxBeginQuote1 != null) {
if (beginQuote == null) {
beginQuote = syntaxBeginQuote1;
@ -445,7 +445,7 @@ class NameImpl {
start = false;
}
}
return (strbuf.toString());
return strbuf.toString();
}
public String toString() {
@ -469,7 +469,7 @@ class NameImpl {
}
if (compsAllEmpty && (size >= 1) && (syntaxSeparator != null))
answer = answer.append(syntaxSeparator);
return (answer.toString());
return answer.toString();
}
public boolean equals(Object obj) {
@ -544,7 +544,7 @@ class NameImpl {
}
public int size() {
return (components.size());
return components.size();
}
public Enumeration<String> getAll() {