Get response should have fields always set, even when there are none

This commit is contained in:
kimchy 2010-04-02 22:11:56 +03:00
parent 408bad62f3
commit 3fb68d62de
1 changed files with 7 additions and 1 deletions

View File

@ -19,6 +19,7 @@
package org.elasticsearch.action.get;
import com.google.common.collect.ImmutableMap;
import org.elasticsearch.ElasticSearchParseException;
import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.util.Unicode;
@ -66,6 +67,9 @@ public class GetResponse implements ActionResponse, Streamable, Iterable<GetFiel
this.exists = exists;
this.source = source;
this.fields = fields;
if (this.fields == null) {
this.fields = ImmutableMap.of();
}
}
/**
@ -155,7 +159,9 @@ public class GetResponse implements ActionResponse, Streamable, Iterable<GetFiel
in.readFully(source);
}
size = in.readVInt();
if (size > 0) {
if (size == 0) {
fields = ImmutableMap.of();
} else {
fields = newHashMapWithExpectedSize(size);
for (int i = 0; i < size; i++) {
GetField field = readGetField(in);