Skip to content

Conversation

horgh
Copy link
Contributor

@horgh horgh commented Aug 25, 2025

This allows users to provide a custom HttpClient for full control over client configuration. When a custom HttpClient is provided, the builder validates that conflicting parameters (connectTimeout, proxy) are not also set, ensuring clear configuration ownership.

🤖 Generated with Claude Code

This allows users to provide a custom HttpClient for full control over
client configuration. When a custom HttpClient is provided, the builder
validates that conflicting parameters (connectTimeout, proxy) are not
also set, ensuring clear configuration ownership.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
+ "Configure timeout on the provided HttpClient instead.");
}
// Check if proxy was changed from default
if (proxy != ProxySelector.getDefault()) {
Copy link
Member

Choose a reason for hiding this comment

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

Should we be using equals here? Does ProxySelector.getDefault() always return the same reference? Perhaps it does, but I didn't dig into it. If it doesn't and we switch to equals, we should make sure it provides an overload that does what we want.

Another option would be to remove the default values above and set these in this method if the values are null.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Happy to change it if you think that's necessary though. Removing the default values might be cleaner generally.

Copy link
Member

Choose a reason for hiding this comment

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

Either way seems fine in that case, but moving the defaults to build might make it less likely that someone copies the pattern for same case where it is not appropriate.

Use null defaults for connectTimeout and proxy in Builder, making
validation cleaner by simply checking for null values. Set defaults
only when no custom HttpClient is provided. Remove unnecessary comments.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@@ -141,7 +141,6 @@ private WebServiceClient(Builder builder) {

requestTimeout = builder.requestTimeout;

// Use custom HttpClient if provided, otherwise create a default one
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure why this comment came out, but it also doesn't seem necessary to keep.

@oschwald oschwald merged commit 1f237fc into main Aug 25, 2025
29 checks passed
@oschwald oschwald deleted the horgh/http-client branch August 25, 2025 18:38
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.

2 participants