diff options
author | Arne H Juul <arnej@yahooinc.com> | 2021-12-08 11:26:00 +0000 |
---|---|---|
committer | Arne H Juul <arnej@yahooinc.com> | 2021-12-08 11:37:50 +0000 |
commit | 88af1ff594695963306a1b136e8e2e22c26651b4 (patch) | |
tree | 4f8f07439e9ab3cd5e14f5e92394938378d05353 /document | |
parent | 2dd0a7ad258fa182ed3ac8a199751dd60f73b0f7 (diff) |
always try reading annotation payload
* even if the serialized datatype ID doesn't match our config,
it's quite possible the payload is OK.
* does it really make sense to "handle it gracefully" and
just ignore the payload? This seems wrong to me, but keep old
behavior for now.
Diffstat (limited to 'document')
-rw-r--r-- | document/src/main/java/com/yahoo/document/serialization/VespaDocumentDeserializer6.java | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/document/src/main/java/com/yahoo/document/serialization/VespaDocumentDeserializer6.java b/document/src/main/java/com/yahoo/document/serialization/VespaDocumentDeserializer6.java index 58cc3c22199..9115a000e20 100644 --- a/document/src/main/java/com/yahoo/document/serialization/VespaDocumentDeserializer6.java +++ b/document/src/main/java/com/yahoo/document/serialization/VespaDocumentDeserializer6.java @@ -714,6 +714,7 @@ public class VespaDocumentDeserializer6 extends BufferSerializer implements Docu byte features = buf.get(); int length = buf.getInt1_2_4Bytes(); + int skipToPos = buf.position() + length; if ((features & (byte) 1) == (byte) 1) { //we have a span node @@ -728,15 +729,19 @@ public class VespaDocumentDeserializer6 extends BufferSerializer implements Docu if ((features & (byte) 2) == (byte) 2) { //we have a value: int dataTypeId = buf.getInt(); - - //if this data type ID the same as the one in our config? - if (dataTypeId != type.getDataType().getId()) { - //not the same, but we will handle it gracefully, and just skip past the data: - buf.position(buf.position() + length - 4); - } else { + try { FieldValue value = type.getDataType().createFieldValue(); value.deserialize(this); annotation.setFieldValue(value); + // could get buffer underflow or DeserializationException + } catch (RuntimeException rte) { + if (dataTypeId == type.getDataType().getId()) { + throw new DeserializationException("Could not deserialize annotation payload", rte); + } + // XXX: does this make sense? The annotation without its payload may be a problem. + // handle it gracefully, and just skip past the data + } finally { + buf.position(skipToPos); } } } |