diff --git a/shield/src/main/java/org/elasticsearch/shield/authc/esusers/tool/ESUsersTool.java b/shield/src/main/java/org/elasticsearch/shield/authc/esusers/tool/ESUsersTool.java index 68678318cce..903f1e72d68 100644 --- a/shield/src/main/java/org/elasticsearch/shield/authc/esusers/tool/ESUsersTool.java +++ b/shield/src/main/java/org/elasticsearch/shield/authc/esusers/tool/ESUsersTool.java @@ -5,7 +5,6 @@ */ package org.elasticsearch.shield.authc.esusers.tool; -import com.google.common.base.Joiner; import com.google.common.collect.ImmutableSet; import org.apache.commons.cli.CommandLine; import org.elasticsearch.common.Strings; @@ -30,6 +29,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.util.*; import java.util.regex.Pattern; +import java.util.stream.Collectors; import static org.elasticsearch.common.cli.CliToolConfig.Builder.cmd; import static org.elasticsearch.common.cli.CliToolConfig.Builder.option; @@ -447,7 +447,7 @@ public class ESUsersTool extends CliTool { String[] roles = userRoles.get(username); Set unknownRoles = Sets.difference(Sets.newHashSet(roles), knownRoles); String[] markedRoles = markUnknownRoles(roles, unknownRoles); - terminal.println("%-15s: %s", username, Joiner.on(",").useForNull("-").join(markedRoles)); + terminal.println("%-15s: %s", username, Arrays.stream(markedRoles).map(s -> s == null ? "-" : s).collect(Collectors.joining(","))); if (!unknownRoles.isEmpty()) { // at least one role is marked... so printing the legend Path rolesFile = FileRolesStore.resolveFile(esusersSettings, env).toAbsolutePath(); @@ -464,7 +464,7 @@ public class ESUsersTool extends CliTool { String[] roles = entry.getValue(); Set unknownRoles = Sets.difference(Sets.newHashSet(roles), knownRoles); String[] markedRoles = markUnknownRoles(roles, unknownRoles); - terminal.println("%-15s: %s", entry.getKey(), Joiner.on(",").join(markedRoles)); + terminal.println("%-15s: %s", entry.getKey(), String.join(",", markedRoles)); unknownRolesFound = unknownRolesFound || !unknownRoles.isEmpty(); usersExist = true; } diff --git a/shield/src/test/java/org/elasticsearch/integration/ClearRealmsCacheTests.java b/shield/src/test/java/org/elasticsearch/integration/ClearRealmsCacheTests.java index 29d352c75d2..fb0f7a8275d 100644 --- a/shield/src/test/java/org/elasticsearch/integration/ClearRealmsCacheTests.java +++ b/shield/src/test/java/org/elasticsearch/integration/ClearRealmsCacheTests.java @@ -5,7 +5,6 @@ */ package org.elasticsearch.integration; -import com.google.common.base.Joiner; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.elasticsearch.action.ActionListener; @@ -123,7 +122,7 @@ public class ClearRealmsCacheTests extends ShieldIntegTestCase { @Override public void executeRequest() throws Exception { String path = "/_shield/realm/" + (randomBoolean() ? "*" : "_all") + "/_cache/clear"; - Map params = Collections.singletonMap("usernames", Joiner.on(',').join(evicted_usernames)); + Map params = Collections.singletonMap("usernames", String.join(",", evicted_usernames)); executeHttpRequest(path, params); } }; diff --git a/watcher/src/main/java/org/elasticsearch/watcher/trigger/schedule/support/MonthTimes.java b/watcher/src/main/java/org/elasticsearch/watcher/trigger/schedule/support/MonthTimes.java index 54d6ad01e6e..ac0da04650f 100644 --- a/watcher/src/main/java/org/elasticsearch/watcher/trigger/schedule/support/MonthTimes.java +++ b/watcher/src/main/java/org/elasticsearch/watcher/trigger/schedule/support/MonthTimes.java @@ -5,11 +5,11 @@ */ package org.elasticsearch.watcher.trigger.schedule.support; -import com.google.common.base.Joiner; import com.google.common.collect.ImmutableSet; import com.google.common.primitives.Ints; import org.elasticsearch.ElasticsearchParseException; import org.elasticsearch.common.ParseFieldMatcher; +import org.elasticsearch.common.Strings; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; @@ -100,7 +100,12 @@ public class MonthTimes implements Times { @Override public String toString() { - return "days [" + Ints.join(",", days) + "], times [" + Joiner.on(",").join(times) + "]"; + return String.format( + Locale.ROOT, + "days [%s], times [%s]", + Ints.join(",", days), + Strings.arrayToCommaDelimitedString(times) + ); } public boolean contains(int day, DayTimes dayTimes) { diff --git a/watcher/src/main/java/org/elasticsearch/watcher/trigger/schedule/support/YearTimes.java b/watcher/src/main/java/org/elasticsearch/watcher/trigger/schedule/support/YearTimes.java index 3c1e3abe5fd..0d39dba167c 100644 --- a/watcher/src/main/java/org/elasticsearch/watcher/trigger/schedule/support/YearTimes.java +++ b/watcher/src/main/java/org/elasticsearch/watcher/trigger/schedule/support/YearTimes.java @@ -5,11 +5,11 @@ */ package org.elasticsearch.watcher.trigger.schedule.support; -import com.google.common.base.Joiner; import com.google.common.collect.ImmutableSet; import com.google.common.primitives.Ints; import org.elasticsearch.ElasticsearchParseException; import org.elasticsearch.common.ParseFieldMatcher; +import org.elasticsearch.common.Strings; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; @@ -73,7 +73,7 @@ public class YearTimes implements Times { String minsStr = Ints.join(",", times.minute); String daysStr = Ints.join(",", this.days); daysStr = daysStr.replace("32", "L"); - String monthsStr = Joiner.on(",").join(months); + String monthsStr = Strings.collectionToCommaDelimitedString(months); String expression = "0 " + minsStr + " " + hrsStr + " " + daysStr + " " + monthsStr + " ?"; crons.add(expression); } @@ -105,7 +105,13 @@ public class YearTimes implements Times { @Override public String toString() { - return "months [" + Joiner.on(",").join(months) + "], days [" + Ints.join(",", days) + "], times [" + Joiner.on(",").join(times) + "]"; + return String.format( + Locale.ROOT, + "months [%s], days [%s], times [%s]", + Strings.collectionToCommaDelimitedString(months), + Ints.join(",", days), + Strings.arrayToCommaDelimitedString(times) + ); } @Override diff --git a/watcher/src/test/java/org/elasticsearch/watcher/trigger/schedule/WeeklyScheduleTests.java b/watcher/src/test/java/org/elasticsearch/watcher/trigger/schedule/WeeklyScheduleTests.java index 92a70100ce8..176d678effb 100644 --- a/watcher/src/test/java/org/elasticsearch/watcher/trigger/schedule/WeeklyScheduleTests.java +++ b/watcher/src/test/java/org/elasticsearch/watcher/trigger/schedule/WeeklyScheduleTests.java @@ -6,9 +6,9 @@ package org.elasticsearch.watcher.trigger.schedule; -import com.google.common.base.Joiner; import com.google.common.primitives.Ints; import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.common.Strings; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; @@ -41,7 +41,7 @@ public class WeeklyScheduleTests extends ScheduleTestCase { String[] crons = expressions(schedule); assertThat(crons, arrayWithSize(time.times().length)); for (DayTimes dayTimes : time.times()) { - assertThat(crons, hasItemInArray("0 " + Ints.join(",", dayTimes.minute()) + " " + Ints.join(",", dayTimes.hour()) + " ? * " + Joiner.on(",").join(time.days()))); + assertThat(crons, hasItemInArray("0 " + Ints.join(",", dayTimes.minute()) + " " + Ints.join(",", dayTimes.hour()) + " ? * " + Strings.collectionToCommaDelimitedString(time.days()))); } } @@ -57,7 +57,7 @@ public class WeeklyScheduleTests extends ScheduleTestCase { assertThat(crons, arrayWithSize(count)); for (WeekTimes weekTimes : times) { for (DayTimes dayTimes : weekTimes.times()) { - assertThat(crons, hasItemInArray("0 " + Ints.join(",", dayTimes.minute()) + " " + Ints.join(",", dayTimes.hour()) + " ? * " + Joiner.on(",").join(weekTimes.days()))); + assertThat(crons, hasItemInArray("0 " + Ints.join(",", dayTimes.minute()) + " " + Ints.join(",", dayTimes.hour()) + " ? * " + Strings.collectionToCommaDelimitedString(weekTimes.days()))); } } } diff --git a/watcher/src/test/java/org/elasticsearch/watcher/trigger/schedule/YearlyScheduleTests.java b/watcher/src/test/java/org/elasticsearch/watcher/trigger/schedule/YearlyScheduleTests.java index 5ac4c8208be..8348bb0853f 100644 --- a/watcher/src/test/java/org/elasticsearch/watcher/trigger/schedule/YearlyScheduleTests.java +++ b/watcher/src/test/java/org/elasticsearch/watcher/trigger/schedule/YearlyScheduleTests.java @@ -6,9 +6,9 @@ package org.elasticsearch.watcher.trigger.schedule; -import com.google.common.base.Joiner; import com.google.common.primitives.Ints; import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.common.Strings; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; @@ -44,7 +44,7 @@ public class YearlyScheduleTests extends ScheduleTestCase { String hrStr = Ints.join(",", dayTimes.hour()); String dayStr = Ints.join(",", time.days()); dayStr = dayStr.replace("32", "L"); - String monthStr = Joiner.on(",").join(time.months()); + String monthStr = Strings.collectionToCommaDelimitedString(time.months()); String expression = "0 " + minStr + " " + hrStr + " " + dayStr + " " + monthStr + " ?"; logger.info("expression: " + expression); assertThat(crons, hasItemInArray(expression)); @@ -67,7 +67,7 @@ public class YearlyScheduleTests extends ScheduleTestCase { String hrStr = Ints.join(",", dayTimes.hour()); String dayStr = Ints.join(",", yearTimes.days()); dayStr = dayStr.replace("32", "L"); - String monthStr = Joiner.on(",").join(yearTimes.months()); + String monthStr = Strings.collectionToCommaDelimitedString(yearTimes.months()); assertThat(crons, hasItemInArray("0 " + minStr + " " + hrStr + " " + dayStr + " " + monthStr + " ?")); } }