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:
Dave Borowitz
2016-11-22 11:40:52 -05:00
parent e502e18ec1
commit ccbb232e64

View File

@@ -151,7 +151,11 @@ class ElasticChangeIndex extends AbstractElasticIndex<Change.Id, ChangeData>
private static <T> List<T> decodeProtos(JsonObject doc, String fieldName,
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())))
.toList();
}