Skip to content

Commit 9bc08ee

Browse files
committed
Tidy up some collections code
1 parent 77f1384 commit 9bc08ee

File tree

1 file changed

+7
-10
lines changed
  • modules/ingest-geoip/qa/geoip-reindexed/src/javaRestTest/java/org/elasticsearch/ingest/geoip

1 file changed

+7
-10
lines changed

modules/ingest-geoip/qa/geoip-reindexed/src/javaRestTest/java/org/elasticsearch/ingest/geoip/GeoIpReindexedIT.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import org.elasticsearch.client.Response;
1919
import org.elasticsearch.client.WarningsHandler;
2020
import org.elasticsearch.common.settings.Settings;
21+
import org.elasticsearch.common.util.CollectionUtils;
2122
import org.elasticsearch.common.util.concurrent.ThreadContext;
2223
import org.elasticsearch.core.Nullable;
2324
import org.elasticsearch.rest.RestStatus;
@@ -34,7 +35,6 @@
3435

3536
import java.io.IOException;
3637
import java.nio.charset.StandardCharsets;
37-
import java.util.ArrayList;
3838
import java.util.Base64;
3939
import java.util.HashSet;
4040
import java.util.List;
@@ -212,9 +212,8 @@ private void testCatIndices(List<String> indexNames, @Nullable List<String> addi
212212
String response = EntityUtils.toString(assertOK(client().performRequest(catIndices)).getEntity());
213213
List<String> indices = List.of(response.trim().split("\\s+"));
214214

215-
if (additionalIndexNames != null && additionalIndexNames.isEmpty() == false) {
216-
indexNames = new ArrayList<>(indexNames); // recopy into a mutable list
217-
indexNames.addAll(additionalIndexNames);
215+
if (additionalIndexNames != null) {
216+
indexNames = CollectionUtils.concatLists(indexNames, additionalIndexNames);
218217
}
219218

220219
assertThat(new HashSet<>(indices), is(new HashSet<>(indexNames)));
@@ -240,9 +239,8 @@ private void testGetStar(List<String> indexNames, @Nullable List<String> additio
240239
);
241240
Response response = assertOK(client().performRequest(getStar));
242241

243-
if (additionalIndexNames != null && additionalIndexNames.isEmpty() == false) {
244-
indexNames = new ArrayList<>(indexNames); // recopy into a mutable list
245-
indexNames.addAll(additionalIndexNames);
242+
if (additionalIndexNames != null) {
243+
indexNames = CollectionUtils.concatLists(indexNames, additionalIndexNames);
246244
}
247245

248246
Map<String, Object> map = responseAsMap(response);
@@ -258,9 +256,8 @@ private void testGetStarAsKibana(List<String> indexNames, @Nullable List<String>
258256
);
259257
Response response = assertOK(client().performRequest(getStar));
260258

261-
if (additionalIndexNames != null && additionalIndexNames.isEmpty() == false) {
262-
indexNames = new ArrayList<>(indexNames); // recopy into a mutable list
263-
indexNames.addAll(additionalIndexNames);
259+
if (additionalIndexNames != null) {
260+
indexNames = CollectionUtils.concatLists(indexNames, additionalIndexNames);
264261
}
265262

266263
Map<String, Object> map = responseAsMap(response);

0 commit comments

Comments
 (0)