Repository navigation
Keep safe response consumer when converting transport options - #1355
Open
RaphaelFakhri wants to merge 1 commit into
Open
RaphaelFakhri wants to merge 1 commit into
RaphaelFakhri wants to merge 1 commit into
Conversation
RestClientOptions.of() and Rest5ClientOptions.of() built converted options from RequestOptions.DEFAULT, so options set with the client builder's transportOptions() or retryConfig(), or passed as DefaultTransportOptions, lost the SafeResponseConsumer that prevents I/O reactor shutdowns. Start from SafeResponseConsumer.DEFAULT_REQUEST_OPTIONS instead, as initialOptions() does.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
RestClientOptions.of()andRest5ClientOptions.of()convert any otherTransportOptionsimplementation by starting fromRequestOptions.DEFAULT. The converted options therefore use the plain response consumer factory instead ofSafeResponseConsumer.DEFAULT_FACTORY, whichinitialOptions()uses to keep errors thrown while consuming a response from shutting down the I/O reactor.This conversion runs on the default setup path. The
ElasticsearchClient.of(...)builder methodstransportOptions(fn)andretryConfig(...)produceDefaultTransportOptions, which the transport then converts:The same happens with
client.withTransportOptions(DefaultTransportOptions)or a customTransportOptions. With either transport, anErrorsuch asOutOfMemoryErrorraised while reading a response can then stop the I/O reactor and leave the client permanently unusable, the failure mode thatSafeResponseConsumerwas added to prevent (#1046, #1049).Change
SafeResponseConsumer.DEFAULT_REQUEST_OPTIONSin bothRestClientOptions.of()andRest5ClientOptions.of(), matchinginitialOptions().RestClientOptionsTestandRest5ClientOptionsTestthat builds a client withtransportOptions(...)and checks that the resulting options useSafeResponseConsumer.DEFAULT_FACTORY.Testing
SafeResponseConsumerTest(both transports) andElasticsearchTransportConfigTest.checkstyleMain,checkstyleTest,forbiddenApisMainandforbiddenApisTestpass.Fixes #1354