Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
### Removed

### Fixed
- Fixed deserialization regression when parsing `failed_shards` in a search result ([#1889](https://github.com/opensearch-project/opensearch-java/pull/1889))

### Security

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@

// typedef: _types.ShardFailure

/**
* <b>NOTE</b> This generated class is used to parse ShardFailure response from two different Opensearch APIs.
* <ul>
* <li><b>ClusterStatistics</b> - as reponse to a search request. Field 'primary' is not in use</li>
* <li><b>ShardInfo</b> - Here 'primary' is supposed to be required</li>
* </ul>>
*
* In v4.x the spec will be changed to use a new generated class 'ShardSearchFailure' to parse response as part of
* ClusterStatistics. But as this is a breaking change, we are keeping the old class for 3.x, making 'primary' not required.
*/
@JsonpDeserializable
@Generated("org.opensearch.client.codegen.CodeGenerator")
public class ShardFailure implements PlainJsonSerializable, ToCopyableBuilder<ShardFailure.Builder, ShardFailure> {
Expand All @@ -66,7 +76,8 @@ public class ShardFailure implements PlainJsonSerializable, ToCopyableBuilder<Sh
@Nullable
private final String node;

private final boolean primary;
@Nullable
private final Boolean primary;

@Nonnull
private final ErrorCause reason;
Expand All @@ -81,7 +92,7 @@ public class ShardFailure implements PlainJsonSerializable, ToCopyableBuilder<Sh
private ShardFailure(Builder builder) {
this.index = builder.index;
this.node = builder.node;
this.primary = ApiTypeHelper.requireNonNull(builder.primary, this, "primary");
this.primary = builder.primary;
this.reason = ApiTypeHelper.requireNonNull(builder.reason, this, "reason");
this.shard = ApiTypeHelper.requireNonNull(builder.shard, this, "shard");
this.status = builder.status;
Expand All @@ -108,9 +119,10 @@ public final String node() {
}

/**
* Required - API name: {@code primary}
* API name: {@code primary}
*/
public final boolean primary() {
@Nullable
public final Boolean primary() {
return this.primary;
}

Expand Down Expand Up @@ -158,8 +170,10 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
generator.write(this.node);
}

generator.writeKey("primary");
generator.write(this.primary);
if (this.primary != null) {
generator.writeKey("primary");
generator.write(this.primary);
}

generator.writeKey("reason");
this.reason.serialize(generator, mapper);
Expand Down Expand Up @@ -194,6 +208,7 @@ public static class Builder extends ObjectBuilderBase implements CopyableBuilder
private String index;
@Nullable
private String node;
@Nullable
private Boolean primary;
private ErrorCause reason;
private Integer shard;
Expand Down Expand Up @@ -245,10 +260,10 @@ public final Builder node(@Nullable String value) {
}

/**
* Required - API name: {@code primary}
* API name: {@code primary}
*/
@Nonnull
public final Builder primary(boolean value) {
public final Builder primary(@Nullable Boolean value) {
this.primary = value;
return this;
}
Expand Down Expand Up @@ -326,7 +341,7 @@ public int hashCode() {
int result = 17;
result = 31 * result + Objects.hashCode(this.index);
result = 31 * result + Objects.hashCode(this.node);
result = 31 * result + Boolean.hashCode(this.primary);
result = 31 * result + Objects.hashCode(this.primary);
result = 31 * result + this.reason.hashCode();
result = 31 * result + Integer.hashCode(this.shard);
result = 31 * result + Objects.hashCode(this.status);
Expand All @@ -340,7 +355,7 @@ public boolean equals(Object o) {
ShardFailure other = (ShardFailure) o;
return Objects.equals(this.index, other.index)
&& Objects.equals(this.node, other.node)
&& this.primary == other.primary
&& Objects.equals(this.primary, other.primary)
&& this.reason.equals(other.reason)
&& this.shard == other.shard
&& Objects.equals(this.status, other.status);
Expand Down
3 changes: 2 additions & 1 deletion java-codegen/opensearch-openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40139,7 +40139,8 @@ components:
primary:
type: boolean
required:
- primary
# NOTE: Manually removed as part of #1889 to fix regression in parsing shard failure search response
# - primary
- reason
- shard
_common___ShardInfo:
Expand Down
Loading