I propose to update to OkHttp 4 for Spring Boot 2.2.x.

Despite being a new major version, it's binary and java-source compatible with OkHttp 3. It even uses the Maven-Coordinates and the package name of OkHttp 3.

More information about this can be found here: https://square.github.io/okhttp/upgrading_to_okhttp_4/

Comment From: wilkinsona

Thanks for the suggestion. I think the switch to OkHttp4 and the introduction of a dependency on Kotlin is too big a change to make in 2.2, particularly after RC. Furthermore, Spring Framework 5.2 compiles and tests against 3.x. Thanks anyway.

Comment From: membersound

I cannot see the point here. I mean, the kotlin dependency is just pulled into the test scope then, not adding into the packaged project. So why not upgrading the library to 4.x?

Comment From: wilkinsona

OkHttp is more than just the mock web server. It is also primarily used as an HTTP client in main application code. This means that moving to 4.x would result in Kotlin being pulled into the packaged project.

Comment From: membersound

Oh ok, that's not what I expected, because as Spring is having RestTemplate and WebClient already, I thought okhttp is used for testing purpose only...

Comment From: scottfrederick

RestTemplate and WebClient don't implement the HTTP transport layer directly, but delegate to external libraries like Apache HttpComponents, OkHttp, Netty, or simply java.net.HttpURLConnection to handle the transport layer.

See ClientHttpRequestFactory in Spring Framework and it's usages in RestTemplateBuilder in Spring Boot for more details.

Comment From: odin568

@wilkinsona The issue is quite old and it was clear to have that rejected to that time. Are there any plans in the meantime as quite some time passed?

Comment From: wilkinsona

We don't have any plans to upgrade at this time. Spring Framework 5.3 continues to compile against 3.x and we continue to feel that version 4's Kotlin dependency is too large for Spring Boot to use that version by default.

Comment From: larsgrefer

What are the Plans for Framework 6.x and Boot 3.x? Will they update to OkHttp 4.x?

Comment From: snicoll

@larsgrefer there's no plan to upgrade to OkHttp 4.x at all at this time for the reason described above.

Comment From: k163377

Is there any update on this issue? As mentioned in the README, OkHttp 3 will not be updated any more, so I think some action is needed. https://github.com/square/okhttp#requirements

Comment From: wilkinsona

@k163377 Any updates will be added to this issue when we have them. Nothing's really changed from our perspective, particularly as Spring Framework continues to depend on 3.x. If you are interested in seeing if the Spring ecosystem can move to OkHttp 4.x, Framework is the place to start.

Comment From: philwebb

We're going to revisit things in 2.x In light of the fact that OkHttp 3 is no longer being supported. Our initial thoughts are that we should upgrade to OkHttp 4 and users that don't like the additional Kotlin stdlib dependency can either downgrade or migrate to something else.

Comment From: wilkinsona

This change is not backwards compatible from Boot's perspective. Tests for RestTemplateBuilder are unable to get the connect and read timeout when using OkHTTP 4.9.3.

Comment From: wilkinsona

Scratch that. It turns out we can improve the tests for 3.14 to use an API that's also available in 4.9.