Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 8.5] Do not mix mapper types in JsonData serialization #442

Merged
merged 1 commit into from Nov 7, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -96,9 +96,15 @@ public <T> T deserialize(JsonpDeserializer<T> deserializer, JsonpMapper mapper)
public void serialize(JsonGenerator generator, JsonpMapper mapper) {
if (value instanceof JsonValue) {
generator.write((JsonValue) value);
} else if (this.mapper == null) {
mapper.serialize(value, generator);
} else if (this.mapper.getClass() != mapper.getClass()) {
// Workaround for https://github.com/elastic/elasticsearch-java/issues/424
// Mappers can require generators to have been created by them (see JacksonJsonpMapper), so use the mapper
// parameter if its class is different from the one passed at construction time.
mapper.serialize(value, generator);
} else {
// Mapper provided at creation time has precedence
(this.mapper != null ? this.mapper : mapper).serialize(value, generator);
this.mapper.serialize(value, generator);
}
}

Expand Down