[BUG] NetworkHttpClient RequestConfig overridden in makeRequest method
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
Hello! Are you still using Twilio-Java version 1.x.x? We are on Twilio-Java version 11.x.x. Can you please upgrade and see if the issue you are facing is resolved? Also, we do not support Java 21 yet.
Hi @manisha1997. I'm using com.twilio.sdk:twilio verison 11.0.1 I already provided a link to the exact line that's causing the issue https://github.com/twilio/twilio-java/blob/main/src/main/java/com/twilio/http/NetworkHttpClient.java#L136