parent
860c94ca60
commit
98a62a6b2d
|
@ -56,7 +56,7 @@ public final class DataStream extends AbstractDiffable<DataStream> implements To
|
|||
public DataStream(String name, TimestampField timeStampField, List<Index> indices, long generation) {
|
||||
this.name = name;
|
||||
this.timeStampField = timeStampField;
|
||||
this.indices = indices;
|
||||
this.indices = Collections.unmodifiableList(indices);
|
||||
this.generation = generation;
|
||||
assert indices.size() > 0;
|
||||
assert indices.get(indices.size() - 1).getName().equals(getDefaultBackingIndexName(name, generation));
|
||||
|
@ -236,12 +236,11 @@ public final class DataStream extends AbstractDiffable<DataStream> implements To
|
|||
"invalid type defined for mapping of timestamp_field";
|
||||
|
||||
this.name = name;
|
||||
this.fieldMapping = fieldMapping;
|
||||
this.fieldMapping = Collections.unmodifiableMap(fieldMapping);
|
||||
}
|
||||
|
||||
public TimestampField(StreamInput in) throws IOException {
|
||||
this.name = in.readString();
|
||||
this.fieldMapping = in.readMap();
|
||||
this(in.readString(), in.readMap());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -181,4 +181,10 @@ public class DataStreamTests extends AbstractSerializingTestCase<DataStream> {
|
|||
Map.of("properties", Map.of("@timestamp", Map.of("type", "date", "meta", Map.of("x", "y")))))))));
|
||||
assertThat(mappings, equalTo(expectedMapping));
|
||||
}
|
||||
|
||||
public void testDataStreamsAreImmutable() {
|
||||
DataStream ds = randomInstance();
|
||||
expectThrows(UnsupportedOperationException.class, () -> ds.getIndices().clear());
|
||||
expectThrows(UnsupportedOperationException.class, () -> ds.getTimeStampField().getFieldMapping().clear());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue