-
Notifications
You must be signed in to change notification settings - Fork 614
✨[client-v2, jdbc-v2] Allow setting http path in URL #2691
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 To request another review, post a new comment with "/windsurf-review".
jdbc-v2/src/main/java/com/clickhouse/jdbc/internal/JdbcConfiguration.java
Show resolved
Hide resolved
jdbc-v2/src/main/java/com/clickhouse/jdbc/internal/JdbcConfiguration.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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 pull request enhances HTTP endpoint URL handling to support custom paths, enabling reverse proxy scenarios and virtual ClickHouse instances. The changes ensure that path components in endpoint URLs are correctly preserved and parsed throughout the client and JDBC layers.
Key changes:
- Modified
Client.Builder.addEndpointto preserve endpoint paths while filtering out query parameters - Updated
JdbcConfiguration.parseUrlto split paths into HTTP path and database name components - Added comprehensive integration tests to verify correct path handling in reverse proxy scenarios
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| client-v2/src/main/java/com/clickhouse/client/api/Client.java | Refactored endpoint URL building to preserve paths and ignore query parameters |
| client-v2/src/test/java/com/clickhouse/client/HttpTransportTests.java | Added integration test for endpoint path preservation with mock reverse proxy scenarios |
| jdbc-v2/src/main/java/com/clickhouse/jdbc/internal/JdbcConfiguration.java | Enhanced URL parsing to extract HTTP path and database name from path segments |
| jdbc-v2/src/test/java/com/clickhouse/jdbc/ConnectionTest.java | Added integration test verifying correct HTTP path routing in JDBC layer |
| jdbc-v2/src/test/java/com/clickhouse/jdbc/internal/JdbcConfigurationTest.java | Improved test assertions with URL context in error messages |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
jdbc-v2/src/main/java/com/clickhouse/jdbc/internal/JdbcConfiguration.java
Show resolved
Hide resolved
jdbc-v2/src/main/java/com/clickhouse/jdbc/internal/JdbcConfiguration.java
Outdated
Show resolved
Hide resolved
Client V2 CoverageCoverage Report
Class Coverage
|
JDBC V2 CoverageCoverage Report
Class Coverage
|
JDBC V1 CoverageCoverage Report
Class Coverage
|
Client V1 CoverageCoverage Report
Class Coverage
|
|
|
This pull request has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in 2 weeks if no further activity occurs. Please feel free to give a status update or ping for review. Thank you for your contributions! |
client-v2/src/main/java/com/clickhouse/client/api/transport/HttpEndpoint.java
Outdated
Show resolved
Hide resolved
client-v2/src/main/java/com/clickhouse/client/api/transport/HttpEndpoint.java
Show resolved
Hide resolved
jdbc-v2/src/test/java/com/clickhouse/jdbc/internal/JdbcConfigurationTest.java
Show resolved
Hide resolved
|



Summary
This pull request improves support for HTTP endpoints with custom paths, which is important for scenarios involving reverse proxies or virtual ClickHouse instances. It ensures that endpoint URLs with paths are correctly parsed and preserved in both the core client and JDBC layers. Comprehensive integration tests are added to verify the new behavior.
Core client improvements:
Client.Builder.addEndpointmethod now preserves the full endpoint path (excluding query parameters) when adding endpoints, enabling support for URLs likehttp://localhost:8123/clickhousefor reverse proxy scenarios.JDBC layer enhancements:
JdbcConfiguration.parseUrlmethod now splits the path into an HTTP path and a database name, ensuring the HTTP path is preserved in the connection URL and the database name is set correctly. For example,/proxy/path/mydbis parsed ashttpPath=/proxy/pathanddatabase=mydb.Testing improvements:
HttpTransportTests) and JDBC (ConnectionTest) to verify that endpoint paths are correctly preserved and requests are routed to the correct HTTP paths. These tests simulate reverse proxy scenarios and check that query parameters in the endpoint URL are ignored. [1] [2]Test assertion enhancements:
JdbcConfigurationTestto include the tested URL in error messages for better debugging. [1] [2]Closes [client-v2] Support changing path name in the URL #2344
Checklist
Delete items not relevant to your PR:
Note
Improves handling of HTTP endpoints with custom paths and aligns client and JDBC behavior for reverse proxy scenarios.
Client (client-v2):
Client.Buildernow storesEndpointobjects;addEndpoint(String)validates protocol/port and preserves path (e.g.,/sales/db).EndpointexposesgetURI/getHost/getPort;HttpEndpointholds host/port/path, builds a path-aware URI, and implements equality/hashCode.Endpoint#getURI(); logs use endpoint object; deprecatedgetEndpoints()now returns endpoint URIs.JDBC (jdbc-v2):
JdbcConfigurationsplits URL path into HTTP path and database (single segment => database), preserves HTTP path in connection URL, and ignores query params for path.Tests:
HttpEndpointpath/IPv6/encoding; improved assertion messages.Written by Cursor Bugbot for commit 9d18d4b. This will update automatically on new commits. Configure here.