ElasticChangeIndex: Fix case when PATCH_SET field not requested
The document does not contain the PATCH_SET field if it wasn't requested, so we should set the value in the ChangeData to null. The implementation of decodeProtos was missing this case. Change-Id: Ib9f254880bef1f534a2ee2f60bdda3fa15b7c73e
This commit is contained in:
@@ -151,7 +151,11 @@ class ElasticChangeIndex extends AbstractElasticIndex<Change.Id, ChangeData>
|
|||||||
|
|
||||||
private static <T> List<T> decodeProtos(JsonObject doc, String fieldName,
|
private static <T> List<T> decodeProtos(JsonObject doc, String fieldName,
|
||||||
ProtobufCodec<T> codec) {
|
ProtobufCodec<T> codec) {
|
||||||
return FluentIterable.from(doc.getAsJsonArray(fieldName))
|
JsonArray field = doc.getAsJsonArray(fieldName);
|
||||||
|
if (field == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return FluentIterable.from(field)
|
||||||
.transform(i -> codec.decode(decodeBase64(i.toString())))
|
.transform(i -> codec.decode(decodeBase64(i.toString())))
|
||||||
.toList();
|
.toList();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user