Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replacing OkHttpClient with Java 11 HttpClient #1218

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

artur-ciocanu
Copy link
Contributor

Description

A few months ago we have upgraded Dapr Java SDK to use Java 11. Java 11 has native support for HTTP client. The proposal is to use the Java 11 HttpClient instead of OkHttpClient. While OkHttpClient is a nice library it adds yet another dependency that we have to manage and upgrade. Also the fact that OkHttpClient uses Kotlin adds another layer of complications since the Kotlin version in OkHttpClient might conflict with our customers Kotlin stdlib.

Issue reference

We strive to have all PR being opened based on an issue, where the problem or feature have been discussed prior to implementation.

Please reference the issue this PR will close: #1217

Checklist

Please make sure you've completed the relevant tasks for this PR, out of the following list:

  • Code compiles correctly
  • Created/updated tests
  • Extended the documentation

@artur-ciocanu artur-ciocanu requested review from a team as code owners February 16, 2025 11:56
@artur-ciocanu artur-ciocanu marked this pull request as draft February 16, 2025 11:57
Artur Ciocanu added 2 commits February 16, 2025 16:19
@artur-ciocanu artur-ciocanu marked this pull request as ready for review February 16, 2025 18:24
@artur-ciocanu
Copy link
Contributor Author

@artursouza @cicoyle and @salaboy please take a look and let me know your thoughts. We are still using OkHttpClient in ITs, but I will take care of those in a separate PR, so this is more focused.

@artur-ciocanu
Copy link
Contributor Author

@artursouza I might need your help, as far as I can see the only failing test WaitForSidecarIT.waitSlow() this test uses ToxiProxy I am not sure why it fails. Is OkHttpClient something smart behind the scenes compare to Java 11 HttpClient?

Artur Ciocanu added 2 commits February 16, 2025 21:21
Signed-off-by: Artur Ciocanu <[email protected]>
int maxRequests = properties.getValue(HTTP_CLIENT_MAX_REQUESTS);
Executor executor = Executors.newFixedThreadPool(maxRequests);
HTTP_CLIENT = HttpClient.newBuilder()
.executor(executor)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When connecting to localhost OkHttpClient use HTTP 1.1 so we need to use the same HTTP protocol version.

@artur-ciocanu
Copy link
Contributor Author

artur-ciocanu commented Feb 17, 2025

@artursouza and @cicoyle with @ThomasVitale's help I have managed to fix the ITs. Everything is 🟢. Could you please review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace OkHttpClient with Java 11 HttpClient
1 participant