Get response should have fields always set, even when there are none
This commit is contained in:
parent
408bad62f3
commit
3fb68d62de
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
package org.elasticsearch.action.get;
|
package org.elasticsearch.action.get;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
import org.elasticsearch.ElasticSearchParseException;
|
import org.elasticsearch.ElasticSearchParseException;
|
||||||
import org.elasticsearch.action.ActionResponse;
|
import org.elasticsearch.action.ActionResponse;
|
||||||
import org.elasticsearch.util.Unicode;
|
import org.elasticsearch.util.Unicode;
|
||||||
|
@ -66,6 +67,9 @@ public class GetResponse implements ActionResponse, Streamable, Iterable<GetFiel
|
||||||
this.exists = exists;
|
this.exists = exists;
|
||||||
this.source = source;
|
this.source = source;
|
||||||
this.fields = fields;
|
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);
|
in.readFully(source);
|
||||||
}
|
}
|
||||||
size = in.readVInt();
|
size = in.readVInt();
|
||||||
if (size > 0) {
|
if (size == 0) {
|
||||||
|
fields = ImmutableMap.of();
|
||||||
|
} else {
|
||||||
fields = newHashMapWithExpectedSize(size);
|
fields = newHashMapWithExpectedSize(size);
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
GetField field = readGetField(in);
|
GetField field = readGetField(in);
|
||||||
|
|
Loading…
Reference in New Issue