[BUG] NetworkHttpClient RequestConfig overridden in makeRequest method
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 527
- Forks
- 453
- Avg merge
- 10h 59m
- Merged PRs (30d)
- 6
Description
Describe the bug
The Twilio SDK allows its users to set different RequestConfig by including code like:
RequestConfig config =
RequestConfig.custom()
.setConnectionRequestTimeout(Timeout.ofMilliseconds(connectionRequestTimeout))
.setResponseTimeout(Timeout.ofMilliseconds(responseTimeout))
.setConnectionKeepAlive(Timeout.ofMilliseconds(connectionKeepAlive))
.build();
NetworkHttpClient httpClient = new NetworkHttpClient(config);
TwilioRestClient client =
new TwilioRestClient.Builder(accountSid, authToken).httpClient(httpClient).build();
Twilio.setRestClient(client);
However, this gets overriden by the request later in
https://github.com/twilio/twilio-java/blob/main/src/main/java/com/twilio/http/NetworkHttpClient.java#L136
So it doesn't allow users to set their own timeouts.
This makes the previous RequestConfig pointless. It would be better to remove the code snippet that sets the RequestConfig for the HttpUriRequestBase in
public Response makeRequest(final Request request) {
...
}
Code snippet
https://github.com/twilio/twilio-java/blob/main/src/main/java/com/twilio/http/NetworkHttpClient.java#L136
httpUriRequestBase.setConfig(DEFAULT_REQUEST_CONFIG);
Actual behavior
RequestConfig set on NetworkHttpClient gets overriden by the request later in
https://github.com/twilio/twilio-java/blob/main/src/main/java/com/twilio/http/NetworkHttpClient.java#L136
So it doesn't allow users to set their own timeouts.
Expected behavior
Remove the code snippet that sets the RequestConfig for the HttpUriRequestBase in
public Response makeRequest(final Request request) {
...
}
so users can use their own RequestConfig
twilio-java version
11.0.1
Java version
21.0.1-amzn
Logs or error messages
No response
Additional context
No response
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
Read src/main/java/com/twilio/http/NetworkHttpClient.java and inspect makeRequest, especially the setConfig call around line 136. Remove the request-level override so the RequestConfig supplied to NetworkHttpClient controls the request timeouts, then verify that custom connection, response, and keep-alive settings are honored.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100