Two spots I found in which we commonly instatiate a non-trivial number of zero length arrays.
This commit is contained in:
parent
df555bb470
commit
d22dd437f1
|
@ -87,9 +87,11 @@ public class ReplicationResponse extends ActionResponse {
|
|||
total = in.readVInt();
|
||||
successful = in.readVInt();
|
||||
int size = in.readVInt();
|
||||
failures = new Failure[size];
|
||||
for (int i = 0; i < size; i++) {
|
||||
failures[i] = new Failure(in);
|
||||
if (size > 0) {
|
||||
failures = new Failure[size];
|
||||
for (int i = 0; i < size; i++) {
|
||||
failures[i] = new Failure(in);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -223,9 +225,9 @@ public class ReplicationResponse extends ActionResponse {
|
|||
private static final String STATUS = "status";
|
||||
private static final String PRIMARY = "primary";
|
||||
|
||||
private ShardId shardId;
|
||||
private String nodeId;
|
||||
private boolean primary;
|
||||
private final ShardId shardId;
|
||||
private final String nodeId;
|
||||
private final boolean primary;
|
||||
|
||||
public Failure(StreamInput in) throws IOException {
|
||||
shardId = new ShardId(in);
|
||||
|
@ -244,9 +246,6 @@ public class ReplicationResponse extends ActionResponse {
|
|||
this.primary = primary;
|
||||
}
|
||||
|
||||
Failure() {
|
||||
}
|
||||
|
||||
public ShardId fullShardId() {
|
||||
return shardId;
|
||||
}
|
||||
|
|
|
@ -306,9 +306,15 @@ public class Lucene {
|
|||
TotalHits totalHits = readTotalHits(in);
|
||||
float maxScore = in.readFloat();
|
||||
|
||||
ScoreDoc[] scoreDocs = new ScoreDoc[in.readVInt()];
|
||||
for (int i = 0; i < scoreDocs.length; i++) {
|
||||
scoreDocs[i] = new ScoreDoc(in.readVInt(), in.readFloat());
|
||||
final int scoreDocCount = in.readVInt();
|
||||
final ScoreDoc[] scoreDocs;
|
||||
if (scoreDocCount == 0) {
|
||||
scoreDocs = EMPTY_SCORE_DOCS;
|
||||
} else {
|
||||
scoreDocs = new ScoreDoc[scoreDocCount];
|
||||
for (int i = 0; i < scoreDocs.length; i++) {
|
||||
scoreDocs[i] = new ScoreDoc(in.readVInt(), in.readFloat());
|
||||
}
|
||||
}
|
||||
return new TopDocsAndMaxScore(new TopDocs(totalHits, scoreDocs), maxScore);
|
||||
} else if (type == 1) {
|
||||
|
|
Loading…
Reference in New Issue