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 2.x] Fixing issues when deserializing response for tasks API #467

Merged
merged 1 commit into from
May 3, 2023
Merged
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 @@ -18,6 +18,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
### Fixed
- Fix missing Highlight and SourceConfig in the MultisearchBody ([#442](https://github.com/opensearch-project/opensearch-java/pull/442))
- Fix search failure with missing required property HitsMetadata.total when trackTotalHits is disabled ([#372](https://github.com/opensearch-project/opensearch-java/pull/372))
- Fix failure when deserialing response for tasks API ([#463](https://github.com/opensearch-project/opensearch-java/pull/463))

### Security

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,38 +67,38 @@ public abstract class BaseNode implements JsonpSerializable {

protected BaseNode(AbstractBuilder<?> builder) {

this.attributes = ApiTypeHelper.unmodifiableRequired(builder.attributes, this, "attributes");
this.host = ApiTypeHelper.requireNonNull(builder.host, this, "host");
this.ip = ApiTypeHelper.requireNonNull(builder.ip, this, "ip");
this.name = ApiTypeHelper.requireNonNull(builder.name, this, "name");
this.attributes = ApiTypeHelper.unmodifiable(builder.attributes);
this.host = builder.host;
this.ip = builder.ip;
this.name = builder.name;
this.roles = ApiTypeHelper.unmodifiable(builder.roles);
this.transportAddress = ApiTypeHelper.requireNonNull(builder.transportAddress, this, "transportAddress");
this.transportAddress = builder.transportAddress;

}

/**
* Required - API name: {@code attributes}
* API name: {@code attributes}
*/
public final Map<String, String> attributes() {
return this.attributes;
}

/**
* Required - API name: {@code host}
* API name: {@code host}
*/
public final String host() {
return this.host;
}

/**
* Required - API name: {@code ip}
* API name: {@code ip}
*/
public final String ip() {
return this.ip;
}

/**
* Required - API name: {@code name}
* API name: {@code name}
*/
public final String name() {
return this.name;
Expand All @@ -112,7 +112,7 @@ public final List<NodeRole> roles() {
}

/**
* Required - API name: {@code transport_address}
* API name: {@code transport_address}
*/
public final String transportAddress() {
return this.transportAddress;
Expand Down Expand Up @@ -166,21 +166,26 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
protected abstract static class AbstractBuilder<BuilderT extends AbstractBuilder<BuilderT>>
extends
ObjectBuilderBase {
@Nullable
private Map<String, String> attributes;

@Nullable
private String host;

@Nullable
private String ip;

@Nullable
private String name;

@Nullable
private List<NodeRole> roles;

@Nullable
private String transportAddress;

/**
* Required - API name: {@code attributes}
* API name: {@code attributes}
* <p>
* Adds all entries of <code>map</code> to <code>attributes</code>.
*/
Expand All @@ -190,7 +195,7 @@ public final BuilderT attributes(Map<String, String> map) {
}

/**
* Required - API name: {@code attributes}
* API name: {@code attributes}
* <p>
* Adds an entry to <code>attributes</code>.
*/
Expand All @@ -200,23 +205,23 @@ public final BuilderT attributes(String key, String value) {
}

/**
* Required - API name: {@code host}
* API name: {@code host}
*/
public final BuilderT host(String value) {
this.host = value;
return self();
}

/**
* Required - API name: {@code ip}
* API name: {@code ip}
*/
public final BuilderT ip(String value) {
this.ip = value;
return self();
}

/**
* Required - API name: {@code name}
* API name: {@code name}
*/
public final BuilderT name(String value) {
this.name = value;
Expand Down Expand Up @@ -244,7 +249,7 @@ public final BuilderT roles(NodeRole value, NodeRole... values) {
}

/**
* Required - API name: {@code transport_address}
* API name: {@code transport_address}
*/
public final BuilderT transportAddress(String value) {
this.transportAddress = value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,22 @@
import static org.hamcrest.Matchers.anEmptyMap;

import java.io.IOException;
import java.util.Arrays;

import org.opensearch.client.opensearch.nodes.NodesStatsResponse;
import org.opensearch.client.opensearch.tasks.ListRequest;
import org.opensearch.client.opensearch.tasks.ListResponse;

public abstract class AbstractNodesIT extends OpenSearchJavaClientTestCase {
public void testNodesStats() throws IOException {
final NodesStatsResponse response = javaClient().nodes().stats();
assertThat(response.clusterName(), not(nullValue()));
assertThat(response.nodes(), not(anEmptyMap()));
}

public void testNodesList() throws IOException {
ListRequest listRequest = new ListRequest.Builder().actions(Arrays.asList("*reindex")).build();
ListResponse listResponse = javaClient().tasks().list();
assertThat(listResponse.nodes(), not(anEmptyMap()));
}
}