-
Notifications
You must be signed in to change notification settings - Fork 186
[FLINK-36236] Fix overriding the connection provider in JdbcSourceBuilder #169
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
…er when set and add tests for the same.
Thanks for opening this pull request! Please check out our contributing guidelines. (https://flink.apache.org/contributing/how-to-contribute.html) |
@eskabetxe Can I get a review please ? Thanks. |
…er when set and add tests for the same.
…er when set and add tests for the same.
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.
LGTM.
My only concern is the change in visibility of some methods in a @PublicEvolving class. I understand they're annotated with @VisibleForTesting, but we should be cautious with such changes.
@1996fanrui can you run CI/CD please
@@eskabetxe the checks have passed. Could you merge the PR ? I don't think I have the permission to do so. Thanks! |
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.
LGTM! Based on the definition (pasted below) @PublicEvolving
I see no harm in restricting the visibility of those getters.
Classes and methods with this annotation are intended for public use and have stable behavior. However, their interfaces and signatures are not considered to be stable and might be changed across versions.
Anyways, will merge this by the end of today if no objections until then, this is a fairly simple change and it is out there for quite a while already. |
Awesome work, congrats on your first merged pull request! |
FLINK-36236: Fix Overriding the Connection Provider in
JdbcSourceBuilder
Summary
This PR fixes an issue where a custom
JdbcConnectionProvider
passed viaJdbcSourceBuilder#setConnectionProvider
was unintentionally overwritten during thebuild()
process. This prevented users from injecting their own connection management logic (e.g., for testing or advanced connection pooling scenarios).Changes
JdbcSourceBuilder
build()
method to only set a defaultSimpleJdbcConnectionProvider
if no custom provider has been set.JdbcSource
getConnectionProvider()
method with@VisibleForTesting
to enable access from test code.Test Coverage
testSetConnectionProvider()
to:null
values are rejected.JdbcSource
retains and uses the explicitly providedJdbcConnectionProvider
.Motivation
This change ensures the builder pattern behaves predictably: user-provided values should not be silently overridden. This is especially important when dependency injection or custom behavior is expected during source initialization.