diff options
author | Arne Juul <arnej@yahoo-inc.com> | 2018-11-01 12:02:42 +0000 |
---|---|---|
committer | Arne Juul <arnej@yahoo-inc.com> | 2018-11-01 12:02:42 +0000 |
commit | 323b12581630540e76c052963f955da1b4ce6be0 (patch) | |
tree | 75b077963f8530a446a58915e8ae3c39e84075df /document | |
parent | f5eb888d310e546e2d98f9028e9c19833475ec5c (diff) |
ensure we write both chunks if they were present
Diffstat (limited to 'document')
-rw-r--r-- | document/src/vespa/document/serialization/vespadocumentserializer.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/document/src/vespa/document/serialization/vespadocumentserializer.cpp b/document/src/vespa/document/serialization/vespadocumentserializer.cpp index 28192cd6a4e..f5059c233bd 100644 --- a/document/src/vespa/document/serialization/vespadocumentserializer.cpp +++ b/document/src/vespa/document/serialization/vespadocumentserializer.cpp @@ -100,6 +100,14 @@ void VespaDocumentSerializer::write(const Document &value, bool hasHeader = false; bool hasBody = false; + const StructFieldValue::Chunks & chunks = value.getFields().getChunks(); + if (chunks.size() == 2) { + // we must assume both types of fields if the original serialization + // had that, even if config has changed since then. + hasHeader = true; + hasBody = true; + } + for (const Field & field : value.getFields()) { if (field.isHeaderField()) { hasHeader = true; @@ -124,7 +132,7 @@ void VespaDocumentSerializer::write(const Document &value, // Currently assume legacy serialization; a chunk will only ever contain fields // _either_ for the header _or_ for the body, never a mixture! // This is to avoid horrible breakage whilst ripping out old guts. - const StructFieldValue::Chunks & chunks = value.getFields().getChunks(); + if (hasHeader) { assert(chunks.size() >= 1); doc_serializer.writeUnchanged(chunks[0]); |