Commit 4cc598ac authored by Johnny Lim's avatar Johnny Lim Committed by Stephane Nicoll

Replace contains() with indexOf()

Closes gh-11373
parent 544c40d4
...@@ -95,8 +95,8 @@ public class AuditEvent implements Serializable { ...@@ -95,8 +95,8 @@ public class AuditEvent implements Serializable {
private static Map<String, Object> convert(String[] data) { private static Map<String, Object> convert(String[] data) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
for (String entry : data) { for (String entry : data) {
if (entry.contains("=")) { int index = entry.indexOf("=");
int index = entry.indexOf("="); if (index != -1) {
result.put(entry.substring(0, index), entry.substring(index + 1)); result.put(entry.substring(0, index), entry.substring(index + 1));
} }
else { else {
......
...@@ -39,7 +39,6 @@ public class Link { ...@@ -39,7 +39,6 @@ public class Link {
public Link(String href) { public Link(String href) {
this.href = href; this.href = href;
this.templated = href.contains("{"); this.templated = href.contains("{");
} }
/** /**
......
...@@ -303,8 +303,9 @@ public class ServerProperties { ...@@ -303,8 +303,9 @@ public class ServerProperties {
public String getServletPrefix() { public String getServletPrefix() {
String result = this.path; String result = this.path;
if (result.contains("*")) { int index = result.indexOf("*");
result = result.substring(0, result.indexOf("*")); if (index != -1) {
result = result.substring(0, index);
} }
if (result.endsWith("/")) { if (result.endsWith("/")) {
result = result.substring(0, result.length() - 1); result = result.substring(0, result.length() - 1);
......
...@@ -498,8 +498,8 @@ public class PropertiesLauncher extends Launcher { ...@@ -498,8 +498,8 @@ public class PropertiesLauncher extends Launcher {
// If home dir is same as parent archive, no need to add it twice. // If home dir is same as parent archive, no need to add it twice.
return null; return null;
} }
if (root.contains("!")) { int index = root.indexOf("!");
int index = root.indexOf("!"); if (index != -1) {
File file = new File(this.home, root.substring(0, index)); File file = new File(this.home, root.substring(0, index));
if (root.startsWith("jar:file:")) { if (root.startsWith("jar:file:")) {
file = new File(root.substring("jar:file:".length(), index)); file = new File(root.substring("jar:file:".length(), index));
......
...@@ -109,8 +109,9 @@ class DocumentRoot { ...@@ -109,8 +109,9 @@ class DocumentRoot {
else { else {
path = location.toURI().getPath(); path = location.toURI().getPath();
} }
if (path.contains("!/")) { int index = path.indexOf("!/");
path = path.substring(0, path.indexOf("!/")); if (index != -1) {
path = path.substring(0, index);
} }
return new File(path); return new File(path);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment