Skip to content

Commit 9767d5f

Browse files
author
Gal-PC\Gal
committed
Fix test, some more defensive copying
1 parent 3211c62 commit 9767d5f

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

server/src/internalClusterTest/java/org/elasticsearch/search/fieldcaps/FieldCapabilitiesIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ public void testFieldAlias() {
233233
assertEquals(1, routeLength.size());
234234

235235
assertTrue(routeLength.containsKey("double"));
236-
assertEquals(new FieldCapabilitiesBuilder("route_length_miles", "double"), routeLength.get("double"));
236+
assertEquals(new FieldCapabilitiesBuilder("route_length_miles", "double").build(), routeLength.get("double"));
237237
}
238238

239239
public void testFieldAliasWithWildcard() {

test/framework/src/main/java/org/elasticsearch/action/fieldcaps/FieldCapabilitiesBuilder.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414

1515
import java.util.Arrays;
1616
import java.util.Collections;
17-
import java.util.HashMap;
1817
import java.util.Map;
1918
import java.util.Set;
19+
import java.util.TreeMap;
2020

2121
public class FieldCapabilitiesBuilder {
2222
private final String name;
@@ -77,27 +77,27 @@ public FieldCapabilitiesBuilder indices(String... indices) {
7777
}
7878

7979
public FieldCapabilitiesBuilder nonSearchableIndices(String... nonSearchableIndices) {
80-
this.nonSearchableIndices = nonSearchableIndices;
80+
this.nonSearchableIndices = Arrays.copyOf(nonSearchableIndices, nonAggregatableIndices.length);
8181
return this;
8282
}
8383

8484
public FieldCapabilitiesBuilder nonAggregatableIndices(String... nonAggregatableIndices) {
85-
this.nonAggregatableIndices = nonAggregatableIndices;
85+
this.nonAggregatableIndices = Arrays.copyOf(nonAggregatableIndices, nonAggregatableIndices.length);
8686
return this;
8787
}
8888

8989
public FieldCapabilitiesBuilder nonDimensionIndices(String... nonDimensionIndices) {
90-
this.nonDimensionIndices = nonDimensionIndices;
90+
this.nonDimensionIndices = Arrays.copyOf(nonDimensionIndices, nonDimensionIndices.length);
9191
return this;
9292
}
9393

9494
public FieldCapabilitiesBuilder metricConflictsIndices(String... metricConflictsIndices) {
95-
this.metricConflictsIndices = metricConflictsIndices;
95+
this.metricConflictsIndices = Arrays.copyOf(metricConflictsIndices, metricConflictsIndices.length);
9696
return this;
9797
}
9898

9999
public FieldCapabilitiesBuilder meta(Map<String, Set<String>> meta) {
100-
this.meta = new HashMap<>(meta);
100+
this.meta = new TreeMap<>(meta);
101101
return this;
102102
}
103103

0 commit comments

Comments
 (0)