Skip to content

Commit

Permalink
Fixed deserialization of SearchRequest when _source is an array
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Farr <[email protected]>
  • Loading branch information
Xtansia committed Aug 1, 2024
1 parent 4d8ec04 commit 714de50
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ This section is for maintaining a changelog for all breaking changes for the cli

### Fixed
- Fixed error when deserializing a normalizer without 'type' ([#1111](https://github.com/opensearch-project/opensearch-java/pull/1111))
- Fixed deserialization of SearchRequest when `_source` is an array ([#]())

### Security

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,12 @@ public void shortcutProperty(String name) {
throw new NoSuchElementException("No deserializer was setup for '" + name + "'");
}

acceptedEvents = EventSetObjectAndString;
this.acceptedEvents = EventSetObjectAndString.clone();

if (this.shortcutProperty instanceof FieldObjectDeserializer) {
JsonpDeserializer<?> shortcutDeserializer = ((FieldObjectDeserializer<?, ?>) this.shortcutProperty).deserializer;
this.acceptedEvents.addAll(shortcutDeserializer.nativeEvents());
}
}

// ----- Object types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,13 @@ public Builder<Union, Kind, Member> addMember(Kind tag, JsonpDeserializer<? exte
);
objectMembers.add(member);
if (od.shortcutProperty() != null) {
// also add it as a string
addMember(Event.VALUE_STRING, tag, member);
// also add it as the shortcut property events
for (Event e : od.acceptedEvents()) {
if (e == Event.START_OBJECT || e == Event.KEY_NAME) {
continue;
}
addMember(e, tag, member);
}
}
} else {
UnionDeserializer.SingleMemberHandler<Union, Kind, Member> member = new SingleMemberHandler<>(tag, deserializer);
Expand Down

0 comments on commit 714de50

Please sign in to comment.