- Notifications
You must be signed in to change notification settings - Fork 615
[client-v2] Fix settings mutability #2550
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
Client V2 CoverageCoverage Report
Class Coverage
|
JDBC V2 CoverageCoverage Report
Class Coverage
|
JDBC V1 CoverageCoverage Report
Class Coverage
|
Client V1 CoverageCoverage Report
Class Coverage
|
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 PR addresses settings mutability issues by implementing a defensive copy pattern for user settings before adjustment. The change prevents side effects when settings are used concurrently for different operations, specifically addressing issue #2543.
- Creates copies of settings objects to prevent unintended mutations of user-provided settings
- Refactors settings classes to use a common
CommonSettingsclass for shared functionality - Adds comprehensive test coverage to verify settings immutability
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| client-v2/src/main/java/com/clickhouse/client/api/internal/CommonSettings.java | New shared settings implementation with copy/merge functionality |
| client-v2/src/main/java/com/clickhouse/client/api/query/QuerySettings.java | Refactored to use CommonSettings with defensive copying |
| client-v2/src/main/java/com/clickhouse/client/api/insert/InsertSettings.java | Refactored to use CommonSettings with defensive copying |
| client-v2/src/main/java/com/clickhouse/client/api/Client.java | Updated to create defensive copies of settings before operations |
| client-v2/src/test/java/com/clickhouse/client/SettingsTests.java | Added comprehensive tests for settings functionality |
| client-v2/src/test/java/com/clickhouse/client/query/QueryTests.java | Added test to verify settings are not mutated during query operations |
| client-v2/src/test/java/com/clickhouse/client/insert/InsertTests.java | Added test to verify settings are not mutated during insert operations |
| jdbc-v2/src/test/java/com/clickhouse/jdbc/PreparedStatementTest.java | Removed test for internal method that no longer exists |
| client-v2/pom.xml | Added Mockito dependency for testing |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| @mzitnik Sonar shows low coverage because of failing because of "low free space" error. |
| */ | ||
| public boolean isClientRequestEnabled() { | ||
| return (Boolean) rawSettings.get("decompress"); | ||
| Boolean flag = (Boolean) settings.getOption(ClientConfigProperties.COMPRESS_CLIENT_REQUEST.getKey()); |
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.
Maybe we should have a method getOptionWithDefault
|



Summary
Makes a copy of user settings before adjustment to prevent side effects when settings used concurrently for different operations.
Closes #2543
Checklist
Delete items not relevant to your PR: