-
Notifications
You must be signed in to change notification settings - Fork 211
Description
What is the bug?
A clear and concise description of the bug.
OpenSearchGenericClient.withTransportOptions(TransportOptions transportOptions).execute(Request request) create a new OpenSearchGenericClient in every execution.
How can one reproduce the bug?
Steps to reproduce the behavior.
- Create OpenSearchTransport with global connection timeout settings. And create OpenSearchGenericClient.
- Most requests use global connection timeout settings to access the server by OpenSearchGenericClient.execute(Request request).
- Some special requests need custom connection timeout settings to access the server by OpenSearchGenericClient.withTransportOptions(TransportOptions transportOptions).execute(Request request).
private static void search(OpenSearchGenericClient client, String endPoint, long connectionTimout) {
Request request = Requests.create("GET", endPoint, null, Map.of(), null);
ApacheHttpClient5Options transportOptions = ApacheHttpClient5Options.DEFAULT.toBuilder()
.setRequestConfig(
RequestConfig.custom().setConnectionRequestTimeout(connectionTimout, TimeUnit.SECONDS).build())
.build();
try {
// each request set connectionTimeout independently
Response response = client.withTransportOptions(transportOptions).execute(request);
System.out.println(response);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
What is the expected behavior?
client.withTransportOptions(transportOptions) create a new OpenSearchGenericClient, each request will create a new client object, it will create many temp client objects
What is your host/environment?
linux
Do you have any screenshots?
If applicable, add screenshots to help explain your problem.