[ES-1436915] Pass context to public classes and their dependencies#806
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR explicitly passes the context object to public classes and their dependencies, ensuring thread safety in multithreaded environments. Key changes include refactoring static utility classes (e.g. MetadataResultSetBuilder) into instance-based classes that take an explicit context, updating client and test code to use the new constructors, and modifying tests to pass a proper connection context.
Reviewed Changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/test/java/com/databricks/jdbc/dbclient/impl/sqlexec/DatabricksMetadataSdkClientTest.java | Fixed a spelling error in a comment. |
| src/test/java/com/databricks/jdbc/dbclient/impl/sqlexec/DatabricksEmptyMetadataClientTest.java | Updated test mocks to pass the connection context explicitly. |
| src/test/java/com/databricks/jdbc/dbclient/impl/common/MetadataResultSetBuilderTest.java | Updated tests to use instance-based MetadataResultSetBuilder. |
| Multiple files under src/main/java/com/databricks/jdbc/… | Replaced static calls to MetadataResultSetBuilder with instance calls using the explicit context. |
Comments suppressed due to low confidence (1)
src/test/java/com/databricks/jdbc/dbclient/impl/sqlexec/DatabricksMetadataSdkClientTest.java:217
- There's a typo in the comment: 'recieved' should be 'received'.
// mockedMetaData represents resultManifest recieved from the server
vikrantpuppala
approved these changes
Apr 25, 2025
gopalldb
approved these changes
Apr 25, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
For public classes and interfaces, we can't make assumptions about the threading environment in which they will be used. Specifically, host applications may utilize these classes, such as ResultSet, in a thread that is different from the one that created the JDBC connection resource.
In the current implementation of certain APIs, along with the execution flow of DatabricksResultSet, there is an expectation that the thread will automatically be populated with an internal context object. This assumption is problematic, given the scenario described above, where threads may not have the expected context object set by default.
To address this issue, this pull request explicitly passes the context object to the areas where it was previously missing, correcting the faulty implementation.
Key changes in this PR:
The metadata result set builder class has been refactored from a static utility class to an instance-based class, with the context object now stored as a member variable.
The context object is now passed explicitly to the DatabricksResultSet class, ensuring that it functions correctly in multithreaded environments.
These changes eliminate the previous assumption about the thread's context
Testing
#807
Additional Notes to the Reviewer