Skip to content

Commit 8a9aeff

Browse files
author
Andrey Turbanov
committed
8287497: Use String.contains() instead of String.indexOf() in java.naming
Reviewed-by: aefimov, rriggs, jpai
1 parent b2ba9fc commit 8a9aeff

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

src/java.naming/share/classes/com/sun/jndi/ldap/LdapAttribute.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -157,7 +157,7 @@ private void setBaseCtxInfo() {
157157
// remove any security credentials - otherwise the serialized form
158158
// would store them in the clear
159159
for (String key : realEnv.keySet()){
160-
if (key.indexOf("security") != -1 ) {
160+
if (key.contains("security")) {
161161

162162
//if we need to remove props, we must do it to a clone
163163
//of the environment. cloning is expensive, so we only do

src/java.naming/share/classes/com/sun/jndi/ldap/LdapClient.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -759,9 +759,9 @@ private boolean isBinaryValued(String attrid,
759759
Hashtable<String, Boolean> binaryAttrs) {
760760
String id = attrid.toLowerCase(Locale.ENGLISH);
761761

762-
return ((id.indexOf(";binary") != -1) ||
762+
return id.contains(";binary") ||
763763
defaultBinaryAttrs.containsKey(id) ||
764-
((binaryAttrs != null) && (binaryAttrs.containsKey(id))));
764+
((binaryAttrs != null) && (binaryAttrs.containsKey(id)));
765765
}
766766

767767
// package entry point; used by Connection

src/java.naming/share/classes/com/sun/jndi/ldap/ext/StartTlsResponseImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ private boolean verify(String hostname, SSLSession session)
426426
* hostname verification is not done for anonymous ciphers
427427
*/
428428
String cipher = session.getCipherSuite();
429-
if (cipher != null && (cipher.indexOf("_anon_") != -1)) {
429+
if (cipher != null && cipher.contains("_anon_")) {
430430
return true;
431431
}
432432
throw e;

src/java.naming/share/classes/javax/naming/NameImpl.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -95,7 +95,7 @@ private final int skipSeparator(String name, int i) {
9595
} else if (isA(name, i, syntaxSeparator2)) {
9696
i += syntaxSeparator2.length();
9797
}
98-
return (i);
98+
return i;
9999
}
100100

101101
private final int extractComp(String name, int i, int len, Vector<String> comps)
@@ -346,7 +346,7 @@ private final String stringifyComp(String comp) {
346346
// determine whether there are any separators; if so escape
347347
// or quote them
348348
if (syntaxSeparator != null &&
349-
comp.indexOf(syntaxSeparator) >= 0) {
349+
comp.contains(syntaxSeparator)) {
350350
if (syntaxBeginQuote1 != null) {
351351
beginQuote = syntaxBeginQuote1;
352352
endQuote = syntaxEndQuote1;
@@ -357,7 +357,7 @@ private final String stringifyComp(String comp) {
357357
escapeSeparator = true;
358358
}
359359
if (syntaxSeparator2 != null &&
360-
comp.indexOf(syntaxSeparator2) >= 0) {
360+
comp.contains(syntaxSeparator2)) {
361361
if (syntaxBeginQuote1 != null) {
362362
if (beginQuote == null) {
363363
beginQuote = syntaxBeginQuote1;
@@ -445,7 +445,7 @@ private final String stringifyComp(String comp) {
445445
start = false;
446446
}
447447
}
448-
return (strbuf.toString());
448+
return strbuf.toString();
449449
}
450450

451451
public String toString() {
@@ -469,7 +469,7 @@ public String toString() {
469469
}
470470
if (compsAllEmpty && (size >= 1) && (syntaxSeparator != null))
471471
answer = answer.append(syntaxSeparator);
472-
return (answer.toString());
472+
return answer.toString();
473473
}
474474

475475
public boolean equals(Object obj) {
@@ -544,7 +544,7 @@ public int compareTo(NameImpl obj) {
544544
}
545545

546546
public int size() {
547-
return (components.size());
547+
return components.size();
548548
}
549549

550550
public Enumeration<String> getAll() {

0 commit comments

Comments
 (0)