Skip to content

Commit

Permalink
Made InlineGet source nullable
Browse files Browse the repository at this point in the history
This addresses the bug in #1042

Developer's Certificate of Origin 1.1
By making a contribution to this project, I certify that:
(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or
(b) The contribution is based upon previous work that, to the
    best of my knowledge, is covered under an appropriate open
    source license and I have the right under that license to
    submit that work with modifications, whether created in whole
    or in part by me, under the same open source license (unless
    I am permitted to submit under a different license), as
    Indicated in the file; or
(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.
(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including
    all personal information I submit with it, including my
    sign-off) is maintained indefinitely and may be redistributed
    consistent with this project or the open source license(s)
    involved.

Signed-off-by: Brendon Faleiro <[email protected]>
  • Loading branch information
Brendon Faleiro committed Jun 20, 2024
1 parent d9bad17 commit c784fdb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ This section is for maintaining a changelog for all breaking changes for the cli
### Dependencies

### Changed
- Made InlineGet source field nullable. ([#1042](https://github.com/opensearch-project/opensearch-java/pull/1042))

### Deprecated

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public class InlineGet<TDocument> implements JsonpSerializable {
@Nullable
private final String routing;

@Nullable
private final TDocument source;

@Nullable
Expand All @@ -84,7 +85,7 @@ private InlineGet(Builder<TDocument> builder) {
this.seqNo = builder.seqNo;
this.primaryTerm = builder.primaryTerm;
this.routing = builder.routing;
this.source = ApiTypeHelper.requireNonNull(builder.source, this, "source");
this.source = builder.source;
this.tDocumentSerializer = builder.tDocumentSerializer;

}
Expand Down Expand Up @@ -139,8 +140,9 @@ public final String routing() {
}

/**
* Required - API name: {@code _source}
* API name: {@code _source}
*/
@Nullable
public final TDocument source() {
return this.source;
}
Expand Down Expand Up @@ -191,8 +193,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
generator.write(this.routing);

}
generator.writeKey("_source");
JsonpUtils.serialize(this.source, generator, tDocumentSerializer, mapper);
if (this.source != null) {
generator.writeKey("_source");
JsonpUtils.serialize(this.source, generator, tDocumentSerializer, mapper);

}

}

Expand Down Expand Up @@ -240,6 +245,7 @@ public final Builder<TDocument> metadata(String key, JsonData value) {
@Nullable
private String routing;

@Nullable
private TDocument source;

@Nullable
Expand Down Expand Up @@ -298,9 +304,9 @@ public final Builder<TDocument> routing(@Nullable String value) {
}

/**
* Required - API name: {@code _source}
* API name: {@code _source}
*/
public final Builder<TDocument> source(TDocument value) {
public final Builder<TDocument> source(@Nullable TDocument value) {
this.source = value;
return this;
}
Expand Down

0 comments on commit c784fdb

Please sign in to comment.