opensearch-project / opensearch-project/opensearch-java
[BUG]why OpenSearchGenericClient.withTransportOptions(TransportOptions transportOptions) create a new OpenSearchGenericClient object?
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 165
- Forks
- 250
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 26
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.
Do you have any additional context?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at OpenSearchGenericClient.withTransportOptions(TransportOptions) and its execute(Request) path; no file or test is named in the report. Trace how transport options are applied and inspect nearby client tests. Done should establish whether each call allocates a client and address the reported per-request allocation without changing the timeout behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100