Skip to content

upgrade to okhttp 5 #1984

Description

@baywet

we need to upgrade ok http to version 5, as this is a breaking release, we'll also need to make sure we include an exclamation mark in the commit message to bump the major version an avoid any upgrade issue for consumers. e.g. eat!:`

Activity

  1. added
    enhancement
    help wanted
    on Jul 4, 2025
  2. moved this to Needs Triage 🔍 in Kiotaon Jul 4, 2025
  3. ramsessanchez commented on Jul 15, 2026

    @ramsessanchez
    Contributor

    Vincent Biret (@baywet) I am currently in the process of making this upgrade across the board, however, I was wondering what would constitute considering this as a breaking release? From what I can tell there isn't any behavior changes that would cause use to raise code breaking changes for our customers or downstream in core and the client libraries.

  4. baywet commented on Jul 16, 2026

    @baywet
    MemberAuthor

    Ramses Sanchez-Hernandez (@ramsessanchez) their changelog documents multiple breaking changes. This is most likely why they major bumped.
    Now, let's assume that somebody has a kiota client in their application, and is also calling into another service using okhttp's APIs. If we push an update of okhttp on them through a minor/patch version, multiple things may happen:

    • if their application has a direct dependency on okhttp v4 (they should since in this scenario their code has a direct dependency), the resolver should complain about conflicting versions (v5 requested by kiota, v4 by their app), making it impossible for them to upgrade until they update their code, and change the version of the dependency in their application. Not something you'd expect via a minor/patch version update.
    • if their application does not have a direct dependency on okhttp v4, the resolver will happily upgrade the packages, but now their app will break at either build time or worse, runtime. Either way, not something you'd expect through a minor/patch version.

    This is a typical diamond dependency problem. Which is why we need to major rev the packages in kiota (and subsequently graph core, graph service libs....)

    Thankfully this is something we've already done in dotnet and we didn't get backlash from the community. So it's probably safe to do the same here. While we're at it, we might want to bundle other binary breaking changes to avoid having too frequent releases. Things like changing the minimum required Android SDK version, target java version etc... (if we need to). It'd be interesting to review the existing issues, todo comments, and point an agent at the repository with a "good prompt" to make sure nothing is missed. (don't let it loose and make the updates right away, have it create issues with detailed rationales first so we can discuss is, and have a record of the decision)

    I hope all of that helps. Let me know if you have any additional comments or questions.

  5. ramsessanchez commented on Aug 31, 2026

    @ramsessanchez
    Contributor

    Proposed direction

    Our current plan is to upgrade OkHttp to version 5. Because this may introduce breaking changes for consumers, the upgrade would require a major-version release of Kiota Java (v2). That major-version change would cascade to the Microsoft Graph Java SDK and its Java core libraries.

    We have also discussed the broader Java platform strategy with the Microsoft identity and Azure SDK for Java teams. Based on those discussions, we propose:

    • Continue supporting Java 8. This preserves stability for existing consumers and keeps us aligned with the Azure SDK for Java and the Microsoft identity libraries.
    • Stop Android-specific validation and testing. The Azure SDK for Java does not provide Android-specific validation, testing, or package releases. Given our current maintenance capacity, we propose following the same model across Kiota Java and the downstream Microsoft Graph Java libraries.
    • Remove the Jakarta Annotations dependency. The latest major version of Jakarta Annotations no longer supports Java 8. To avoid tying our Java support policy to that dependency, we propose using Microsoft-owned annotation providers or standard JDK annotations where possible.

    This would not intentionally make the packages incompatible with Android. However, we would no longer maintain Android-specific packages or infrastructure, or validate and guarantee Android compatibility. Consumers could continue using the standard Java packages on Android where they work.

    Before we move forward, we would appreciate feedback from Vincent Biret (@baywet) and other Java experts on this direction, particularly the proposed Java 8 support policy, the scope of Android support, and the replacement for Jakarta Annotations. Are there compatibility concerns or downstream impacts we should account for as part of these major-version releases?

    This major-version update is also an opportunity to review our remaining dependencies. Are there other dependencies we should remove or replace to reduce our exposure to future changes in Java or tooling compatibility?

  6. baywet commented on Sep 1, 2026

    @baywet
    MemberAuthor

    Thank you for the additional information.

    I have a couple of remarks here.

    Stop Android-specific validation and testing

    Why is that a cost today? It's validated by the CI, doesn't require significant work, and at least gives an option to android devs rather than none. I'm not in favour of dropping android support in Java unless we fund some alternative, like Kotlin for instance.

    Remove the Jakarta Annotations dependency.

    What's this Microsoft owned alternative? do you have any pointers to share?

    CC Andrea Peruffo (@andreaTP)

  7. andreaTP commented on Sep 1, 2026

    @andreaTP
    Contributor

    I’d strongly argue against continuing to maintain Java 8 compatibility in 2026.
    The ecosystem has moved on, and keeping such an old baseline will increasingly mean a significant maintenance burden, while also limiting access to upstream libraries fixes and support.

    For context, both Spring 6 and Quarkus have already moved to Java 17 as their baseline. In my hands-on experience with other projects, even maintaining Java 11 compatibility is becoming a significant burden.

    Given that the Kiota libraries are interchangeable, I’d propose the opposite approach: drop the old compatibility constraints and make Java 17 the baseline.
    Users who need to remain on Java 8 can still do so, but I think the engineering burden of supporting that old runtime should sit with the consumer rather than the library maintainers.

    I don’t have a specific requirement for Android, although I suspect there are users benefiting from the current compatibility there, so that’s probably worth considering separately.

    As for Jakarta, I think that problem will largely solve itself once the Java baseline is raised.

  8. baywet commented on Sep 1, 2026

    @baywet
    MemberAuthor

    Andrea Peruffo (@andreaTP) thanks for the input here!

    Ramses Sanchez-Hernandez (@ramsessanchez) I think a data point that'd significantly help settle the "should we support android" discussion would be to use the component governance dashboard to see whether any internal Android application has a dependency on kiota. I know intune used to be a huge consumer early on, I wonder whether that's still the case.

    Another data point is that we DON'T have any issue requesting Kotlin support at this point (but that could be self-fulfilling since those users might be using Java today)

    Another aspect is that we have support for dart.

    Another data point is that Google itself is building its apps using kotlin, encouraging people to do the same and the ecosystem has followed

  9. papegaaij commented on Sep 2, 2026

    @papegaaij
    Contributor

    I agree with Andrea on the Java 8 support. It's even highly debatable if Java 11 support is actually a good idea. You are locking yourself out of many options that have long become industry standard. I would go for 17 as a minimum. This whole ticket can be a none-issue if you switch to JDK 11 for example: from that version there's a Http client included in the JDK.

    With respect to the annotations. I don't know what the annotations are used for, but the industry has long moved to the Jakarta namespace. Introducing your own set of annotations seems like the worst of all to me. Nobody will support those.

    Trying to support these old versions can even make it hard or impossible to use the libraries on newer platforms. So you'll be dropping support for customers that do keep their versions up to date in favor of those neglecting to upgrade.

  10. andreaTP commented on Sep 2, 2026

    @andreaTP
    Contributor

    Thanks Emond Papegaaij (@papegaaij) for the thoughtful message!
    For reference I already have an implementation using the JDK built-in Http Client here.

  11. baywet commented on Sep 2, 2026

    @baywet
    MemberAuthor

    Thank you for jumping in, and pointing out the native alternative. The benefits being: it would allow us to drop a dependency. But that would come at a significant rewrite cost (middleware handler, etc...) and it's not supported by android. Worth considering if the team decides to drop android support in the end.

  12. maxandersen commented on Sep 2, 2026

    @maxandersen

    fwiw, agree with that if you are bumping things in a breaking way anyway basing on Java 17 is the new "base bottom" for java libraries"

  13. MelleD commented on Nov 17, 2026

    @MelleD

    Is there any news or are there any plans here, because okhttp 4.x have now CVEs. Because of this hard dep

    Because of this hard dependency, we can't upgrade to 5.x.x. We use the msgraph-sdk-java.

    We didn't encounter any breaking changes during our migration; we just had to include okhttp-jvm instead of okhttp.

  14. 2 remaining items

  15. MelleD commented on Nov 17, 2026

    @MelleD

    Andrea Peruffo (@andreaTP)

    Only change was that body is not nullable anymore:
    MelleD#1

    I also adapted core as well and removed the okhttp dep, because it comes transitive from kitoa-okhttp would not declare it twice, but to you can add tomorrow as well a branch here.

    Missing part is the graph-sdk with my project but I think can test it as well this week

  16. andreaTP commented on Nov 17, 2026

    @andreaTP
    Contributor

    Dennis Melzer (@MelleD) thanks a lot for the spike, that's good context.

    Since this is taking very long to unfold, a practical proposal would be to host the OkHttp 5 implementation (friendly fork 🙂) in the kiota-community repository, after is published people should be able to swap out the default and in the OkHttp5 even in graph (IIUC).

    Wdyt Vincent Biret (@baywet) ?

  17. MelleD commented on Nov 17, 2026

    @MelleD

    Just for complete picture. Both can remove okhttp directly because it is transitive
    MelleD/msgraph-sdk-java-core#1
    MelleD/msgraph-sdk-java#1

    Local all tests are running. Have to test with my application but I think it's working. So I think no breaking change so far. Maybe this nullable thing not sure if it was intended to work with null body.

    Android I cannot say :), maybe someone have to test

  18. baywet commented on Nov 17, 2026

    @baywet
    MemberAuthor

    Dennis Melzer (@MelleD) thanks for looking into this. I don't believe we can remove the dependency from the Microsoft Graph libs since there's direct usage and public API dependencies on the package
    https://github.com/search?q=repo%3Amicrosoftgraph%2Fmsgraph-sdk-java+okhttp+language%3AJava&type=code&l=Java
    https://github.com/search?q=repo%3Amicrosoftgraph%2Fmsgraph-sdk-java-core+okhttp+language%3AJava&type=code&l=Java

    However, on that front, the last major version is almost 3 years old, so I don't think we'd get a lot of push back doing a major bump, especially if it's security related. As we do that, we should also evaluate SDK targets (android) and jdk versions.

    Andrea Peruffo (@andreaTP) thanks for following up the conversation here. I don't think a soft fork of the package would do a service to the community and maybe create more confusion than anything if that makes sense?

  19. andreaTP commented on Nov 17, 2026

    @andreaTP
    Contributor

    maybe create more confusion than anything if that makes sense?

    If you have a more structural solution I'm totally for it, I was proposing a (temporary?) workaround when we struggle to have a close.

  20. added
    type:breaking-change
    on Nov 17, 2026
  21. baywet commented on Nov 17, 2026

    @baywet
    MemberAuthor

    to be clear, I'm suggesting we move forward, but also coordinate with other breaking changes. Assuming that Gavin Barron (@gavinbarron) doesn't have any issue with this.

  22. MelleD commented on Nov 18, 2026

    @MelleD

    Vincent Biret (@baywet) I lost track. What’s the breaking change for you? Is it the nullable body handling, or something else?

    But you can remove OkHttp from both projects because it’s included transitively via Kiota. You only need to add it if you want to override Kiota’s OkHttp version.
    For example, if Kiota has OKHTTP 5.0.0 and the Graph SDK wants to use 5.1.0, then the Graph SDK must include those dependencies.

    My branches are already running fine with a clean install and the snapshots, even without the dependencies. The classpath is also exactly the same as before.

    EDIT from graph sdk:
    Here is the tree without direct dep:

    Bildschirmfoto 2026-11-18 um 09 13 03
  23. MelleD commented on Nov 18, 2026

    @MelleD

    Test with my project and 3 branches:

    No breaking changes all test passed:

    Dep tree how expected only kiota http have the dep included on single place:

    Bildschirmfoto 2026-11-18 um 09 18 56

    E.g.

    Bildschirmfoto 2026-11-18 um 09 21 08

    If you want I can prepare PRs for all 3 repos, changes are very small. Test running locally also fine

  24. baywet commented on Nov 18, 2026

    @baywet
    MemberAuthor

    on removing the dependency from the microsoft graph packages

    I understand that it works but since those types are part of the public API of those packages, they should declare the dependency themselves. In the (unlikely) cases where kiota removes okhttp, makes it private, or that msgraph doesn't use kiota anymore, it'd be broken if they didn't. It also impacts how the javadoc works as well I believe, but that's beyond my expertise.

    on why it's a breaking change.

    That's because projects might rely on OkHttp APIs that are changing from 4 to 5 in their code, or have a dependency that does. And if kiota upgrades okhttp, they end up in a diamond dependency situation (effectively the same situation you're trying to currently solve, but with version numbers reversed).

    I hope that clarifies things a little?

  25. MelleD commented on Nov 18, 2026

    @MelleD

    I understand that it works but since those types are part of the public API of those packages, they should declare the dependency themselves. In the (unlikely) cases where kiota removes okhttp, makes it private, or that msgraph doesn't use kiota anymore, it'd be broken if they didn't. It also impacts how the javadoc works as well I believe, but that's beyond my expertis

    That's just how Maven works, if Kiota removes it along with a (new) version, then the graph (since it's necessary at that point) should add the required Maven dependencies.
    It would simply reduce the effort involved with the versions, and right now, declaring it offers no advantage and only creates extra work.
    I'm just speaking from my own experience with Maven about how I would do it, but it's your decision.
    For me, it doesn’t matter whether it’s part of the public API or not. I don’t see any connection there.

    I hope that clarifies things a little?

    It's really a matter of perspective whether you consider the breaking changes in a library to be breaking changes for your client as well. We see the same discussions way too often with Spring Boot, it's a matter of perspective. But okay, for me, a new major version is fine

    by the way that are the breaking changes:
    a) Response.Builder.body(null) is not allowed
    b) OkHttpClient.clone() is replaced with newBuilder().build()
    c) maven artifact id is okttp-jvm, but IMHO should nobody declare directly because it comes transitive

    New MockWebServer3 changed api from path → target

  26. andreaTP commented on Nov 18, 2026

    @andreaTP
    Contributor

    Trying to sum up where I land on this:

    Major version bump: yes. kiota-http-okHttp is a thin layer over OkHttp, and OkHttp types are part of its public API (KiotaClientFactory.create() returns an OkHttpClient.Builder, every middleware is an okhttp3.Interceptor, and OkHttp is an api dependency). OkHttp's major version is effectively part of our contract, so our versioning should reflect it. That also avoids the diamond-dependency surprise Vincent Biret (@baywet) described.

    No Java baseline change needed. OkHttp 5 still supports Java 8+ (README). I checked the 5.5.1 artifacts: okhttp-jvm, okio-jvm 3.18.1 and kotlin-stdlib 2.1.21 all ship Java 8 bytecode. We already target 1.8, so this upgrade is independent of the Java 8 vs 17 discussion, which we can settle separately.

    Android: little to no change. OkHttp 5 requires API 21+, and we already require minSdk 26. Gradle-based Android builds pick up the okhttp-android AAR automatically through Gradle module metadata. The one thing to get right is publishing: for Maven users the plain okhttp artifact is now empty, so our POM should point at okhttp-jvm while our Gradle metadata keeps okhttp. That's how OkHttp's own logging-interceptor is published.
    Switching our dependency to okhttp-jvm everywhere isn't enough: Android apps would then get the JVM jar instead of the Android AAR, losing OkHttp's Android-specific code. If the app also depends on okhttp itself, it would end up with both artifacts and duplicate classes.

    The code changes look small (see Dennis Melzer (@MelleD)'s spike: mainly Response.Builder.body(null) no longer being allowed), and the legacy okhttp3.mockwebserver artifact is still published for 5.x, so our existing tests can keep using it.

    All in all, I vote for upgrading to OkHttp 5 and shipping it as the next major release.

  27. MelleD commented on Nov 19, 2026

    @MelleD

    Switching our dependency to okhttp-jvm everywhere isn't enough: Android apps would then get the JVM jar instead of the Android AAR, losing OkHttp's Android-specific code. If the app also depends on okhttp itself, it would end up with both artifacts and duplicate classes.

    Yes I added this in graph sdk https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp-android
    I hope there are tests around because have no android projekt. Do you see more places to add okhttp-android?

  28. MelleD commented on Nov 20, 2026

    @MelleD

    Andrea Peruffo (@andreaTP) & Vincent Biret (@baywet)

    My Proposal is:

    1. Kiota: This is where the platform is determined
      In Kiota, I would declare the dependency as follows:
      api(libs.com.squareup.okhttp3.okhttp)

    In other words, just the generic okhttp artifact—not okhttp-jvm as well.

    This allows Gradle to select the appropriate variant based on the published Gradle Module Metadata.

    Maven user have to decide if they need android or jvm for gradle should work

    1. Core: No Separate OkHttp Dependency
      I would removes the direct OkHttp dependency and updates Kiota to 2.0.0.

    I think that’s fundamentally the right approach.

    In the Core, I wouldn’t add either okhttp-jvm or okhttp-android.

    Why?

    • Core uses Kiota as its HTTP abstraction.
    • The specific OkHttp implementation comes via Kiota’s HTTP module.
    • An additional OkHttp dependency would duplicate responsibilities again.
    1. Graph SDK: Android needs to be considered separately here
    • pom.xml for Maven
    • android/build.gradle for Android
      This makes sense in principle, since there are indeed different build systems here.

    I would handle it as follows:

    Android (android/build.gradle)

    If the Kiota metadata does not automatically provide the Android variant, specify it explicitly:

    dependencies {
        implementation ‘com.squareup.okhttp3:okhttp-android:5.5.1’
    }
    

    But this is up for an test, I would expect gradle choose the right android already. But better safe than sorry we could add this there.

    Make sure that okhttp-jvm is not additionally included transitively.
    For Maven projects, the situation is different: Maven does not support Gradle Module Metadata and therefore does not automatically choose between JVM and Android.

    In this case, the JVM variant must be used, so I would remove okhttp (because comes from kiota) but add directly okhttp-jvm

  29. MelleD commented on Nov 24, 2026

    @MelleD

    The Android build now uses JDK 17 or newer, but the library’s Java bytecode target remains Java 8 (targetCompatibility = 1.8). JVM consumers were also tested on Java 8.

    The Android build-tool upgrade was driven by OkHttp 5.5.1: its Android artifact requires compileSdk 37, for which Android’s current guidance requires AGP 9.1.1 or later and Gradle 9. AGP 8.13 already requires JDK 17, but officially supports only up to API 36.1. So the prior comment was right that Gradle 9 cannot run on JDK 8;

    For dependency selection, Gradle can choose the Android OkHttp variant automatically when Gradle module metadata is available. If an Android build uses only the Maven POM, it must exclude transitive okhttp-jvm and add okhttp-android explicitly to avoid including both variants. As far as I know there is no other way for maven and did it like other frameworks (spring tomcat vs jetty).

    So the plan was not complete working as described, because build was breaking, but maybe easier to see the result to better discussion:

    #2262

    Gradle works with metadata:
    Maven ships okhttp-jvm as default

    Therefore the other two projects needs no deps, because it's transitive:
    microsoftgraph/msgraph-sdk-java-core#2170
    microsoftgraph/msgraph-sdk-java#2719

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementhelp wantedtype:breaking-change

    Type

    No type

    Projects

    • Status
      Needs Triage 🔍

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions