do real copies where copyOf was used before

This commit is contained in:
Ryan Ernst 2015-08-24 21:22:21 -07:00
parent 69ba45a797
commit 01cfa95d1c
7 changed files with 13 additions and 10 deletions

View File

@ -611,7 +611,7 @@ public class IndexShardRoutingTable implements Iterable<ShardRouting> {
}
public IndexShardRoutingTable build() {
return new IndexShardRoutingTable(shardId, Collections.unmodifiableList(shards));
return new IndexShardRoutingTable(shardId, Collections.unmodifiableList(new ArrayList<>(shards)));
}
public static IndexShardRoutingTable readFrom(StreamInput in) throws IOException {

View File

@ -141,7 +141,7 @@ public class DanglingIndicesState extends AbstractComponent {
return;
}
try {
allocateDangledIndices.allocateDangled(Collections.unmodifiableCollection(danglingIndices.values()), new LocalAllocateDangledIndices.Listener() {
allocateDangledIndices.allocateDangled(Collections.unmodifiableCollection(new ArrayList<>(danglingIndices.values())), new LocalAllocateDangledIndices.Listener() {
@Override
public void onResponse(LocalAllocateDangledIndices.AllocateDangledResponse response) {
logger.trace("allocated dangled");

View File

@ -22,6 +22,7 @@ package org.elasticsearch.index.shard;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.index.store.StoreFileMetaData;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@ -89,8 +90,8 @@ public class CommitPoint {
this.version = version;
this.name = name;
this.type = type;
this.indexFiles = Collections.unmodifiableList(indexFiles);
this.translogFiles = Collections.unmodifiableList(translogFiles);
this.indexFiles = Collections.unmodifiableList(new ArrayList<>(indexFiles));
this.translogFiles = Collections.unmodifiableList(new ArrayList<>(translogFiles));
}
public long version() {

View File

@ -27,6 +27,7 @@ import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.common.xcontent.XContentType;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
@ -46,7 +47,7 @@ public class CommitPoints implements Iterable<CommitPoint> {
return (o2.version() < o1.version() ? -1 : (o2.version() == o1.version() ? 0 : 1));
}
});
this.commitPoints = Collections.unmodifiableList(commitPoints);
this.commitPoints = Collections.unmodifiableList(new ArrayList<>(commitPoints));
}
public List<CommitPoint> commits() {

View File

@ -32,6 +32,7 @@ import org.elasticsearch.common.xcontent.*;
import org.elasticsearch.index.store.StoreFileMetaData;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@ -342,7 +343,7 @@ public class BlobStoreIndexShardSnapshot implements ToXContent, FromXContentBuil
assert indexVersion >= 0;
this.snapshot = snapshot;
this.indexVersion = indexVersion;
this.indexFiles = Collections.unmodifiableList(indexFiles);
this.indexFiles = Collections.unmodifiableList(new ArrayList<>(indexFiles));
this.startTime = startTime;
this.time = time;
this.numberOfFiles = numberOfFiles;

View File

@ -51,7 +51,7 @@ public class BlobStoreIndexShardSnapshots implements Iterable<SnapshotFiles>, To
private final ImmutableMap<String, List<FileInfo>> physicalFiles;
public BlobStoreIndexShardSnapshots(List<SnapshotFiles> shardSnapshots) {
this.shardSnapshots = Collections.unmodifiableList(shardSnapshots);
this.shardSnapshots = Collections.unmodifiableList(new ArrayList<>(shardSnapshots));
// Map between blob names and file info
Map<String, FileInfo> newFiles = newHashMap();
// Map between original physical names and file info
@ -77,7 +77,7 @@ public class BlobStoreIndexShardSnapshots implements Iterable<SnapshotFiles>, To
}
ImmutableMap.Builder<String, List<FileInfo>> mapBuilder = ImmutableMap.builder();
for (Map.Entry<String, List<FileInfo>> entry : physicalFiles.entrySet()) {
mapBuilder.put(entry.getKey(), Collections.unmodifiableList(entry.getValue()));
mapBuilder.put(entry.getKey(), Collections.unmodifiableList(new ArrayList<>(entry.getValue())));
}
this.physicalFiles = mapBuilder.build();
this.files = ImmutableMap.copyOf(newFiles);
@ -99,7 +99,7 @@ public class BlobStoreIndexShardSnapshots implements Iterable<SnapshotFiles>, To
}
ImmutableMap.Builder<String, List<FileInfo>> mapBuilder = ImmutableMap.builder();
for (Map.Entry<String, List<FileInfo>> entry : physicalFiles.entrySet()) {
mapBuilder.put(entry.getKey(), Collections.unmodifiableList(entry.getValue()));
mapBuilder.put(entry.getKey(), Collections.unmodifiableList(new ArrayList<>(entry.getValue())));
}
this.physicalFiles = mapBuilder.build();
}

View File

@ -116,7 +116,7 @@ public class SnapshotUtils {
}
}
if (result == null) {
return Arrays.asList(selectedIndices);
return Collections.unmodifiableList(new ArrayList<>(Arrays.asList(selectedIndices)));
}
return Collections.unmodifiableList(new ArrayList<>(result));
}