Use Java 8 String.join()
Change-Id: I74a002b562a39b5971e4f7877be6bc258cb64715
diff --git a/src/main/java/com/googlesource/gerrit/plugins/its/base/util/IssueExtractor.java b/src/main/java/com/googlesource/gerrit/plugins/its/base/util/IssueExtractor.java
index 5c344f1..fd37249 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/its/base/util/IssueExtractor.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/its/base/util/IssueExtractor.java
@@ -1,5 +1,7 @@
package com.googlesource.gerrit.plugins.its.base.util;
+import static java.util.Arrays.copyOfRange;
+
import com.google.common.base.Strings;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
@@ -17,7 +19,6 @@
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -156,13 +157,11 @@
if (footerStart == -1) {
// No footer could be found. So all lines after the first one (that's
// the subject) is the body.
- //body = String[] templateParameters =
- // Arrays.copyOfRange(allParameters, 1, allParameters.length);
if (lines.length > 0) {
- body = StringUtils.join(lines, "\n", 1, lines.length);
+ body = String.join("\n", copyOfRange(lines, 1, lines.length));
}
} else {
- body = StringUtils.join(lines, "\n", 1, footerStart - 1);
+ body = String.join("\n", copyOfRange(lines, 1, footerStart - 1));
StringBuilder footerBuilder = new StringBuilder();
for (int lineIdx = footerStart; lineIdx < footerEnd; lineIdx++) {
@@ -182,7 +181,7 @@
}
footerBuilder.append(line);
}
- footer = StringUtils.join(lines, "\n", footerStart, footerEnd);
+ footer = String.join("\n", copyOfRange(lines, footerStart, footerEnd));
}
if (body != null) {
addIssuesOccurrence(body, "body", ret);
diff --git a/src/main/java/com/googlesource/gerrit/plugins/its/base/workflow/action/AddComment.java b/src/main/java/com/googlesource/gerrit/plugins/its/base/workflow/action/AddComment.java
index 16855d3..51f976c 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/its/base/workflow/action/AddComment.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/its/base/workflow/action/AddComment.java
@@ -21,7 +21,6 @@
import com.googlesource.gerrit.plugins.its.base.workflow.Property;
import java.io.IOException;
import java.util.Set;
-import org.apache.commons.lang.StringUtils;
/**
* Adds a fixed comment to an issue.
@@ -43,8 +42,7 @@
@Override
public void execute(String issue, ActionRequest actionRequest, Set<Property> properties)
throws IOException {
- String[] parameters = actionRequest.getParameters();
- String comment = StringUtils.join(parameters, " ");
+ String comment = String.join(" ", actionRequest.getParameters());
if (!Strings.isNullOrEmpty(comment)) {
its.addComment(issue, comment);
}