1818import org .elasticsearch .client .Response ;
1919import org .elasticsearch .client .WarningsHandler ;
2020import org .elasticsearch .common .settings .Settings ;
21+ import org .elasticsearch .common .util .CollectionUtils ;
2122import org .elasticsearch .common .util .concurrent .ThreadContext ;
2223import org .elasticsearch .core .Nullable ;
2324import org .elasticsearch .rest .RestStatus ;
3435
3536import java .io .IOException ;
3637import java .nio .charset .StandardCharsets ;
37- import java .util .ArrayList ;
3838import java .util .Base64 ;
3939import java .util .HashSet ;
4040import 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