Skip to content

KTOR-9559 Add dnsResolver config to Apache5 engine#5571

Merged
bjhham merged 1 commit intoktorio:mainfrom
fru1tworld:feat/apache5-dns-config
May 5, 2026
Merged

KTOR-9559 Add dnsResolver config to Apache5 engine#5571
bjhham merged 1 commit intoktorio:mainfrom
fru1tworld:feat/apache5-dns-config

Conversation

@fru1tworld
Copy link
Copy Markdown
Contributor

@fru1tworld fru1tworld commented May 1, 2026

Subsystem
Client / Apache5 engine

Motivation
KTOR-9559 (umbrella: KTOR-462) / #1678 / #1924

Apache HttpClient 5 has a DnsResolver interface but Apache5EngineConfig does not surface it as a first-class option. Users currently have to drop down to engine { configureConnectionManager { setDnsResolver(...) } } to inject a custom resolver.

Solution
Add Apache5EngineConfig.dnsResolver: DnsResolver? and apply it on the PoolingAsyncClientConnectionManagerBuilder before configureConnectionManager. Defaults to null → Apache's default resolver is used as before.

HttpClient(Apache5) {
    engine {
        dnsResolver = SystemDefaultDnsResolver.INSTANCE
    }
}

Follow-up to the OkHttp dns config PR (#5570); same per-engine pattern. The unified resolver abstraction (KTOR-462) remains out of scope.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 1, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: df11505d-c7b8-4d14-b777-e6caa3042f2c

📥 Commits

Reviewing files that changed from the base of the PR and between 7230205 and 5e87237.

📒 Files selected for processing (4)
  • ktor-client/ktor-client-apache5/api/ktor-client-apache5.api
  • ktor-client/ktor-client-apache5/jvm/src/io/ktor/client/engine/apache5/Apache5Engine.kt
  • ktor-client/ktor-client-apache5/jvm/src/io/ktor/client/engine/apache5/Apache5EngineConfig.kt
  • ktor-client/ktor-client-apache5/jvm/test/io/ktor/client/engine/apache5/Apache5EngineConfigTest.kt
✅ Files skipped from review due to trivial changes (1)
  • ktor-client/ktor-client-apache5/jvm/src/io/ktor/client/engine/apache5/Apache5EngineConfig.kt
🚧 Files skipped from review as they are similar to previous changes (3)
  • ktor-client/ktor-client-apache5/jvm/src/io/ktor/client/engine/apache5/Apache5Engine.kt
  • ktor-client/ktor-client-apache5/api/ktor-client-apache5.api
  • ktor-client/ktor-client-apache5/jvm/test/io/ktor/client/engine/apache5/Apache5EngineConfigTest.kt

📝 Walkthrough

Walkthrough

Adds optional DNS resolver support to the Apache5 engine: new nullable dnsResolver property and public getter/setter on Apache5EngineConfig, wiring to the Apache connection manager when present, and a test verifying resolver invocation.

Changes

DNS resolver support

Layer / File(s) Summary
Data Shape / Config
ktor-client/ktor-client-apache5/jvm/src/io/ktor/client/engine/apache5/Apache5EngineConfig.kt
Adds public var dnsResolver: DnsResolver? = null and imports org.apache.hc.client5.http.DnsResolver with KDoc describing behavior.
API surface
ktor-client/ktor-client-apache5/api/ktor-client-apache5.api
Exports Apache5EngineConfig.getDnsResolver(): DnsResolver and Apache5EngineConfig.setDnsResolver(DnsResolver): void.
Core Implementation / Wiring
ktor-client/ktor-client-apache5/jvm/src/io/ktor/client/engine/apache5/Apache5Engine.kt
Connection manager builder chain now applies setDnsResolver(it) when config.dnsResolver is non-null.
Tests
ktor-client/ktor-client-apache5/jvm/test/io/ktor/client/engine/apache5/Apache5EngineConfigTest.kt
New test injects a custom DnsResolver, performs a request, and asserts the resolver was invoked (call counter > 0).

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • ktorio/ktor#5094: Touches PoolingAsyncClientConnectionManagerBuilder configuration in the Apache5 engine and overlaps with connection manager customization discussed here.

Suggested reviewers

  • bjhham
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and accurately summarizes the main change: adding a dnsResolver config option to the Apache5 engine, matching the core objective of the PR.
Description check ✅ Passed The description follows the template structure with all required sections (Subsystem, Motivation, Solution) properly filled. It provides specific issue references, clear problem statement, and concrete solution with example usage.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

Copy link
Copy Markdown
Contributor

@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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@ktor-client/ktor-client-apache5/api/ktor-client-apache5.api`:
- Around line 16-23: The ABI dump lists getDnsResolver and setDnsResolver as
non-nullable, but the source property dnsResolver is nullable; regenerate the
Kotlin ABI for the module so the signatures reflect nullability (getDnsResolver
returns Lorg/apache/hc/client5/http/DnsResolver;? and setDnsResolver accepts a
nullable parameter). Run the project task to update the ABI dump (e.g.,
./gradlew :ktor-client-apache5:updateKotlinAbi) and commit the updated
ktor-client-apache5.api so getDnsResolver, setDnsResolver and the dnsResolver
property signatures match the source nullability.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: cce3911b-2f9f-4b66-87cd-c6195afa3e73

📥 Commits

Reviewing files that changed from the base of the PR and between 295e688 and 7230205.

📒 Files selected for processing (4)
  • ktor-client/ktor-client-apache5/api/ktor-client-apache5.api
  • ktor-client/ktor-client-apache5/jvm/src/io/ktor/client/engine/apache5/Apache5Engine.kt
  • ktor-client/ktor-client-apache5/jvm/src/io/ktor/client/engine/apache5/Apache5EngineConfig.kt
  • ktor-client/ktor-client-apache5/jvm/test/io/ktor/client/engine/apache5/Apache5EngineConfigTest.kt

Comment thread ktor-client/ktor-client-apache5/api/ktor-client-apache5.api
@fru1tworld fru1tworld changed the title KTOR-462 Add dnsResolver config to Apache5 engine Add dnsResolver config to Apache5 engine May 5, 2026
Copy link
Copy Markdown
Contributor

@bjhham bjhham left a comment

Choose a reason for hiding this comment

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

Looks good 👍

I've added a new YouTrack issue for tracking KTOR-9559 DNS configuration for the Apache5 client

@fru1tworld fru1tworld force-pushed the feat/apache5-dns-config branch from 7230205 to 5e87237 Compare May 5, 2026 08:09
@fru1tworld fru1tworld changed the title Add dnsResolver config to Apache5 engine KTOR-9559 Add dnsResolver config to Apache5 engine May 5, 2026
@fru1tworld
Copy link
Copy Markdown
Contributor Author

Thanks for the review! Updated to reference KTOR-9559 in the commit/title 😄

@bjhham bjhham enabled auto-merge (rebase) May 5, 2026 13:54
@bjhham bjhham merged commit 5629119 into ktorio:main May 5, 2026
17 checks passed
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.

2 participants