Skip to content

Conversation

@ttypic
Copy link
Contributor

@ttypic ttypic commented Nov 20, 2025

  • Updated build scripts to use network-client-okhttp by default where appropriate.
  • Revised README to simplify proxy setup instructions.
  • Adjusted integration workflows to correctly configure HTTP client preferences.

Summary by CodeRabbit

  • Documentation

    • Updated proxy guidance to use ProxyOptions in ClientOptions and removed OkHttp-specific dependency instructions.
  • Chores

    • Renamed CI test jobs and adjusted test flags to run the httpURLConnection variant and disable the OkHttp variant in relevant workflows; added a conditional test flag for a specific Android API level.
    • Inverted default network-client selection in builds and updated Android runtime dependency and dependency resolution rules.
  • Refactor

    • Centralized HTTP response body handling to improve resource and error management.

✏️ Tip: You can customize this high-level summary in your review settings.

@ttypic ttypic requested a review from sacOO7 November 20, 2025 23:57
@coderabbitai
Copy link

coderabbitai bot commented Nov 20, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

CI jobs were renamed to run the HttpURLConnection variant; Gradle property logic was inverted so OkHttp is the default unless -PhttpURLConnection is set; Android build now conditionally uses the OkHttp network client; OkHttp response-body extraction was refactored into a helper; README proxy example now uses ProxyOptions.

Changes

Cohort / File(s) Summary
CI workflows
.github/workflows/integration-test.yml, .github/workflows/emulate.yml
Renamed jobs check-restcheck-rest-httpurlconnection and check-realtimecheck-realtime-httpurlconnection; added -PhttpURLConnection to :java:testRestSuite and :java:testRealtimeSuite invocations; removed -Pokhttp flags from okhttp-specific runs. Emulate workflow conditionally appends -PhttpURLConnection for Android API level 19.
Java build logic
java/build.gradle.kts
Inverted property check: selection now depends on httpURLConnection property so OkHttp is the default unless -PhttpURLConnection is provided.
Android build
android/build.gradle.kts
Runtime network-client dependency made conditional: uses network-client-okhttp by default unless -PhttpURLConnection is set; added a resolutionStrategy forcing a JetBrains library version.
OkHttp implementation
network-client-okhttp/src/main/java/.../OkHttpCall.java
Extracted response-body handling into private buildHttpBody(Response) helper that safely reads ResponseBody, derives MediaType/content-type, and returns a HttpBody or null; execute() delegates to this helper.
Documentation
README.md
Removed OkHttp-based proxy dependency guidance and replaced the proxy example with ProxyOptions configured via ClientOptions for AblyRest/AblyRealtime usage.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant Client as Client code
    participant OkCall as OkHttpCall
    participant OkHttp as OkHttpClient
    participant Helper as buildHttpBody()
    Client->>OkCall: execute(request)
    OkCall->>OkHttp: newCall(request).execute()
    OkHttp-->>OkCall: Response
    OkCall->>Helper: buildHttpBody(Response)
    alt content-type present
        Helper-->>OkCall: HttpBody (constructed)
    else no content-type
        Helper-->>OkCall: null
    end
    OkCall-->>Client: Response + optional HttpBody
Loading
sequenceDiagram
    autonumber
    participant Push as CI push
    participant Workflow as integration-test.yml
    participant Gradle as Gradle
    Push->>Workflow: trigger integration tests
    Workflow->>Gradle: ./gradlew :java:testRestSuite -PhttpURLConnection
    Workflow->>Gradle: ./gradlew :java:testRealtimeSuite -PhttpURLConnection
    note right of Gradle: okhttp-specific runs no longer include -Pokhttp flag
    Gradle-->>Workflow: test results & artifacts
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Focus areas:
    • network-client-okhttp/src/.../OkHttpCall.java — validate safe ResponseBody consumption, MediaType handling, and resource closure.
    • java/build.gradle.kts, android/build.gradle.kts, .github/workflows/* — confirm property inversion and CI/test flag changes behave as intended.
    • README.md — ensure proxy guidance matches runtime behavior and removed okhttp instructions are fully replaced.

Poem

🐰 I hop through lines of code so fine,
Flags flipped, clients swapped in a line.
A helper nibbles bodies neat and small,
ProxyOptions now answer the call.
I twitch my nose and hop away with a byte!

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Title check ⚠️ Warning The title does not accurately reflect the main changes in the PR. The PR is primarily about inverting the default network client logic to use httpURLConnection by default instead of OkHttp, which is the opposite of what the title states. Update the title to reflect the actual change, such as 'refactor: make httpURLConnection the default network client' or 'refactor: invert default network client selection logic'.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch make-okhttp-default

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot temporarily deployed to staging/pull/1180/features November 20, 2025 23:58 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1180/javadoc November 21, 2025 00:00 Inactive
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 4f354a8 and 64f62a9.

📒 Files selected for processing (4)
  • .github/workflows/integration-test.yml (5 hunks)
  • README.md (1 hunks)
  • android/build.gradle.kts (1 hunks)
  • java/build.gradle.kts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (12)
  • GitHub Check: check-realtime-okhttp
  • GitHub Check: check-rest-okhttp
  • GitHub Check: check
  • GitHub Check: check-liveobjects
  • GitHub Check: check (29)
  • GitHub Check: build
  • GitHub Check: check-rest-httpurlconnection
  • GitHub Check: check (19)
  • GitHub Check: check-realtime-httpurlconnection
  • GitHub Check: check (29)
  • GitHub Check: check (21)
  • GitHub Check: check (24)
🔇 Additional comments (3)
android/build.gradle.kts (1)

57-57: Make OkHttp explicit as Android's runtime network client.

Switching to runtimeOnly scope for network-client-okhttp appropriately makes OkHttp the default HTTP client for Android users without exposing OkHttp internals at compile time. This aligns with the SDK's shift to OkHttp as the default across all platforms.

README.md (1)

130-178: Clear and practical proxy setup documentation.

The updated proxy guidance using ProxyOptions is cleaner and more user-friendly than requiring explicit OkHttp dependency management. The code example comprehensively covers both REST and Realtime clients with optional authentication, making it straightforward for users to implement proxy support.

Verify that all classes and fields referenced in the example (ProxyOptions, HttpAuth.Type.BASIC, HttpAuth.Type.DIGEST) exist and have the expected API.

.github/workflows/integration-test.yml (1)

11-92: Test matrix comprehensively covers both HTTP client variants; verify branch protection configuration.

The updated workflow maintains test coverage for both OkHttp (default via okhttp jobs without the property) and HttpURLConnection (via httpurlconnection jobs with -PhttpURLConnection). The renamed jobs clearly indicate what's being tested.

Repository scan found no internal references to the old job names. However, verify that any branch protection rules on the main branch have been updated to reference the new job names (check-rest-httpurlconnection, check-realtime-httpurlconnection, check-rest-okhttp, check-realtime-okhttp). Check this in GitHub repository settings under Branches → Branch protection rules and ensure required status checks reference the correct job names.

@sacOO7 sacOO7 requested a review from Copilot November 21, 2025 12:53
Copy link
Collaborator

@sacOO7 sacOO7 left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the network client configuration to use OkHttp as the default HTTP client instead of HttpURLConnection. The change simplifies proxy setup by making OkHttp (which has better proxy support) the default choice while still allowing users to opt-in to HttpURLConnection when needed.

  • Inverted the build logic to make OkHttp the default network client, with HttpURLConnection as an opt-in via property flag
  • Updated CI/CD workflows to test both HTTP client implementations separately
  • Simplified README documentation by removing OkHttp-specific dependency instructions since it's now the default

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
java/build.gradle.kts Inverted dependency logic to use network-client-okhttp by default, falling back to network-client-default (HttpURLConnection) when -PhttpURLConnection property is set
android/build.gradle.kts Changed Android builds to unconditionally use network-client-okhttp as the runtime dependency
README.md Removed OkHttp dependency installation instructions from proxy setup guide since OkHttp is now the default
.github/workflows/integration-test.yml Renamed and restructured test jobs to explicitly test both HTTP client variants, with httpurlconnection tests using -PhttpURLConnection flag and okhttp tests running without flags
Comments suppressed due to low confidence (1)

.github/workflows/integration-test.yml:57

  • The artifact name for the Realtime test reports will conflict between the httpurlconnection and okhttp test jobs. When both check-realtime-httpurlconnection and check-realtime-okhttp jobs run, they will both try to upload artifacts with the name java-build-reports-realtime, causing one to overwrite the other.

Consider making the artifact name unique by including the HTTP client variant, for example: java-build-reports-realtime-httpurlconnection.

      - uses: actions/upload-artifact@v4
        if: always()
        with:
          name: java-build-reports-realtime
          path: java/build/reports/

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ttypic ttypic force-pushed the make-okhttp-default branch from 64f62a9 to e26bc88 Compare November 24, 2025 15:42
@github-actions github-actions bot temporarily deployed to staging/pull/1180/features November 24, 2025 15:43 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1180/javadoc November 24, 2025 15:45 Inactive
@ttypic ttypic force-pushed the make-okhttp-default branch from e26bc88 to cc1cd37 Compare November 24, 2025 16:17
@github-actions github-actions bot temporarily deployed to staging/pull/1180/features November 24, 2025 16:18 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1180/javadoc November 24, 2025 16:20 Inactive
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
.github/workflows/integration-test.yml (1)

58-75: Consider uploading artifacts for OkHttp test jobs.

The check-rest-okhttp and check-realtime-okhttp jobs don't upload test reports, while the httpurlconnection variants do (lines 29-33, 53-57). This inconsistency may make debugging OkHttp test failures more difficult.

Consider adding artifact uploads for consistency:

- uses: actions/upload-artifact@v4
  if: always()
  with:
    name: java-build-reports-rest-okhttp
    path: java/build/reports/

Also applies to: 76-93

♻️ Duplicate comments (1)
java/build.gradle.kts (1)

25-29: Breaking change still requires documentation.

The inverted logic that makes OkHttp the default network client remains undocumented. The previous review comment correctly identified this as a breaking change requiring CHANGELOG entries and README updates.

As noted in the previous review: add entries to CHANGELOG.md documenting the default change and add a section to README.md explaining HTTP client selection and the -PhttpURLConnection flag.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between e26bc88 and cc1cd37.

📒 Files selected for processing (5)
  • .github/workflows/integration-test.yml (5 hunks)
  • README.md (1 hunks)
  • android/build.gradle.kts (1 hunks)
  • java/build.gradle.kts (1 hunks)
  • network-client-okhttp/src/main/java/io/ably/lib/network/OkHttpCall.java (3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
network-client-okhttp/src/main/java/io/ably/lib/network/OkHttpCall.java (1)
lib/src/main/java/io/ably/lib/http/HttpCore.java (1)
  • Response (530-568)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (12)
  • GitHub Check: check (29)
  • GitHub Check: check
  • GitHub Check: check-liveobjects
  • GitHub Check: check-realtime-okhttp
  • GitHub Check: check-realtime-httpurlconnection
  • GitHub Check: build
  • GitHub Check: check-rest-httpurlconnection
  • GitHub Check: check (24)
  • GitHub Check: check-rest-okhttp
  • GitHub Check: check (29)
  • GitHub Check: check (19)
  • GitHub Check: check (21)
🔇 Additional comments (5)
android/build.gradle.kts (1)

57-57: LGTM: Android now uses OkHttp by default.

This change aligns with the PR's objective to make OkHttp the default network client for Android.

README.md (1)

137-137: LGTM: Simplified proxy setup documentation.

The updated documentation correctly reflects the streamlined proxy configuration using ProxyOptions, removing the previous OkHttp-specific guidance. The example code is clear and complete.

.github/workflows/integration-test.yml (2)

11-11: LGTM: Job names now clearly indicate HTTP client variant.

The renamed jobs (check-rest-httpurlconnection and check-realtime-httpurlconnection) improve clarity by explicitly identifying which HTTP client implementation is being tested.

Also applies to: 35-35


27-27: LGTM: Test flags correctly aligned with inverted default.

The httpurlconnection jobs now use -PhttpURLConnection to test the non-default client, while okhttp jobs run without flags to test the new OkHttp default. This correctly validates both network client implementations.

Also applies to: 51-51, 74-74, 92-92

network-client-okhttp/src/main/java/io/ably/lib/network/OkHttpCall.java (1)

44-51: The review comment is based on an incorrect assumption about the code behavior.

The buildHttpBody method correctly returns null when contentType is null. This is intentional design, not a bug:

  1. Content-Type is required for deserialization: Without a Content-Type header, the response body bytes cannot be properly interpreted or deserialized. Returning null is the correct response.

  2. Framework explicitly expects null bodies: HttpCore.java (line 477) shows the pattern: if (response.statusCode == HttpURLConnection.HTTP_NO_CONTENT || rawResponse.getBody() == null) — the framework treats null bodies as valid and expected for certain responses (e.g., 204 No Content).

  3. Callers properly handle null: The framework consistently checks for null before accessing body content (HttpCore.java line 481), confirming this pattern is intentional.

  4. Lombok builder accepts null: HttpResponse uses @Builder with no @NonNull constraint on the body field, so null is a valid value.

Likely an incorrect or invalid review comment.

… support setup

- Updated build scripts to use `network-client-okhttp` by default where appropriate.
- Revised README to simplify proxy setup instructions.
- Adjusted integration workflows to correctly configure HTTP client preferences.
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
.github/workflows/emulate.yml (1)

42-42: Conditional flag application aligns with build default inversion.

Line 42 correctly applies -PhttpURLConnection only for API level 19, allowing other API levels to use the new OkHttp default. Verify that API 19's specific requirement for HttpURLConnection is documented (e.g., via inline comment or linked issue/PR) to prevent future maintenance confusion about why this API level is special-cased.

Consider adding a clarifying inline comment above the script line:

          disable-animations: true
          # Print emulator logs if tests fail
+         # API 19 uses HttpURLConnection; other levels use OkHttp (the new default)
          script: ./gradlew :android:connectedAndroidTest ${{ matrix.android-api-level == 19 && '-PhttpURLConnection' || '' }} || (adb logcat -d System.out:I && exit 1)
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between cc1cd37 and c3018d7.

📒 Files selected for processing (6)
  • .github/workflows/emulate.yml (1 hunks)
  • .github/workflows/integration-test.yml (5 hunks)
  • README.md (1 hunks)
  • android/build.gradle.kts (1 hunks)
  • java/build.gradle.kts (1 hunks)
  • network-client-okhttp/src/main/java/io/ably/lib/network/OkHttpCall.java (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • network-client-okhttp/src/main/java/io/ably/lib/network/OkHttpCall.java
  • android/build.gradle.kts
  • README.md
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (12)
  • GitHub Check: check (29)
  • GitHub Check: check
  • GitHub Check: check-realtime-okhttp
  • GitHub Check: check-rest-okhttp
  • GitHub Check: check (29)
  • GitHub Check: check-rest-httpurlconnection
  • GitHub Check: check (21)
  • GitHub Check: check-realtime-httpurlconnection
  • GitHub Check: check (19)
  • GitHub Check: check (24)
  • GitHub Check: check-liveobjects
  • GitHub Check: build
🔇 Additional comments (1)
.github/workflows/integration-test.yml (1)

11-34: The artifact naming concern is unfounded—okhttp variant jobs do not upload artifacts.

Verification of the full workflow file shows:

  • check-rest-httpurlconnection uploads to java-build-reports-rest
  • check-rest-okhttp has no artifact upload step (only runs gradle)
  • check-realtime-httpurlconnection uploads to java-build-reports-realtime
  • check-realtime-okhttp has no artifact upload step (only runs gradle)

The review comment incorrectly assumed okhttp jobs would upload artifacts with identical names. They do not upload artifacts at all, so there is no collision. The suggested diff changes are unnecessary.

Likely an incorrect or invalid review comment.

@ttypic ttypic merged commit cd51650 into main Nov 25, 2025
14 checks passed
@ttypic ttypic deleted the make-okhttp-default branch November 25, 2025 11:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants