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 9 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

artur-ciocanu commented Feb 16, 2025

@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 doing 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]>
@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.

@salaboy
Copy link
Contributor

salaboy commented Feb 20, 2025

@artur-ciocanu this looks good to me.. just the license header is missing on that one file

Signed-off-by: Artur Ciocanu <[email protected]>
cicoyle
cicoyle previously approved these changes Feb 20, 2025
Copy link
Contributor

@cicoyle cicoyle left a comment

Choose a reason for hiding this comment

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

lgtm. Thanks for adding the READ_TIMEOUT for consistency

@artursouza
Copy link
Member

Thanks a lot @artur-ciocanu. I have two questions above. The point about the test is that in Project Reactor, all actions need to be lazily resolved - we validate it by making sure nothing is invoked until .block() is called. This is basic expectations.

Now, there is a major piece of work that we can consider (another PR), which is to move the SDK away from Project Reactor and use CompletableFuture only (https://www.baeldung.com/java-asynchronous-programming#completableFuture). I am not in favor of using another 3rd party async API anymore :)

@artur-ciocanu
Copy link
Contributor Author

@artursouza I have added back the test related to multiple Monos, could you please take another look. Thank you!

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
4 participants