Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static Rest5ClientOptions of(@Nullable TransportOptions options) {
return (Rest5ClientOptions) options;
}

final Builder builder = new Builder(RequestOptions.DEFAULT.toBuilder());
final Builder builder = new Builder(SafeResponseConsumer.DEFAULT_REQUEST_OPTIONS.toBuilder());
options.headers().forEach(h -> builder.addHeader(h.getKey(), h.getValue()));
options.queryParameters().forEach(builder::setParameter);
builder.onWarnings(options.onWarnings());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static RestClientOptions of(@Nullable TransportOptions options) {
return (RestClientOptions)options;
}

final Builder builder = new Builder(RequestOptions.DEFAULT.toBuilder());
final Builder builder = new Builder(SafeResponseConsumer.DEFAULT_REQUEST_OPTIONS.toBuilder());
options.headers().forEach(h -> builder.addHeader(h.getKey(), h.getValue()));
options.queryParameters().forEach(builder::setParameter);
builder.onWarnings(options.onWarnings());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,4 +199,19 @@ void testRequestOptionsOverridingBuiltin() throws Exception {
// overriding user-agent is ok
checkUserAgent(id, "FooBarAgent/1.0");
}

@Test
void testConvertedOptionsUseSafeResponseConsumer() throws Exception {
// Transport options set on the client builder are converted from DefaultTransportOptions
ElasticsearchClient esClient = ElasticsearchClient.of(b -> b
.host("http://example.com")
.transportOptions(o -> o.addHeader("Foo", "bar"))
);

Rest5ClientOptions options = (Rest5ClientOptions) esClient._transportOptions();
assertSame(SafeResponseConsumer.DEFAULT_FACTORY,
options.restClientRequestOptions().getHttpAsyncResponseConsumerFactory());

esClient._transport().close();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -199,4 +199,20 @@ void testRequestOptionsOverridingBuiltin() throws Exception {
// overriding user-agent is ok
checkUserAgent(id, "FooBarAgent/1.0");
}

@Test
void testConvertedOptionsUseSafeResponseConsumer() throws Exception {
// Transport options set on the client builder are converted from DefaultTransportOptions
ElasticsearchClient esClient = ElasticsearchClient.of(b -> b
.host("http://example.com")
.useLegacyTransport(true)
.transportOptions(o -> o.addHeader("Foo", "bar"))
);

RestClientOptions options = (RestClientOptions) esClient._transportOptions();
assertSame(SafeResponseConsumer.DEFAULT_FACTORY,
options.restClientRequestOptions().getHttpAsyncResponseConsumerFactory());

esClient._transport().close();
}
}