Skip to content

DataSourceBuilder should only alias a property when the expected DataSource is configured #23480

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

Closed
snicoll opened this issue Sep 24, 2020 · 8 comments
Assignees
Labels
type: bug A general bug
Milestone

Comments

@snicoll
Copy link
Member

snicoll commented Sep 24, 2020

DataSourceBuilder has a number of aliases to accommodate for small changes in API. For instance, Hikari has a jdbc-url rather than the more common url property so we have a mapping for that. This mapping is useless if the DataSource we configure isn't using Hikari.

So far we got away with it, but adding support for Oracle UCP means we need to add yet another alias that's actually a valid property for DBCP2 (yet referring to something completely different).

@snicoll snicoll added the type: bug A general bug label Sep 24, 2020
@snicoll snicoll added this to the 2.4.x milestone Sep 24, 2020
@snicoll snicoll changed the title DataSourceBuilder should only alias a property when the expected DataSource is configured ConfigurationPropertyNameAliases should not use alias once the value has been bound Sep 24, 2020
@snicoll
Copy link
Member Author

snicoll commented Sep 24, 2020

Taking a step back, it's rather ConfigurationPropertyNameAliases that attempts to bind to any alias that is configured irrespective to the fact that the "main property" has been bound.

snicoll added a commit to snicoll/spring-boot that referenced this issue Sep 24, 2020
@snicoll
Copy link
Member Author

snicoll commented Sep 24, 2020

To reproduce quickly the issue, you need to patch DataSourceBuilder as follows and the run CommonsDbcp2DataSourcePoolMetadataTests. Both setDriverClassName and setConnectionFactoryClassName will be invoked because those two properties are present in the environment.

@philwebb
Copy link
Member

Unfortunately we might not be able to fix this one by changing the alias logic. The alias feature is part of ConfigurationPropertySource and the Binder isn't aware of it. I think we'll need to go back to only adding aliases when we know the DataSource type supports them.

snicoll added a commit to snicoll/spring-boot that referenced this issue Sep 25, 2020
snicoll added a commit to snicoll/spring-boot that referenced this issue Sep 25, 2020
snicoll added a commit to snicoll/spring-boot that referenced this issue Sep 25, 2020
snicoll added a commit to snicoll/spring-boot that referenced this issue Sep 25, 2020
snicoll added a commit to snicoll/spring-boot that referenced this issue Sep 25, 2020
snicoll added a commit to snicoll/spring-boot that referenced this issue Sep 25, 2020
@fabio-grassi-gbs
Copy link
Contributor

I committed a change in pull request #23403 that doesn't use ConfigurationPropertySource in favour of plain BeanWrapper plus some custom logic local to DataSourceBuilder. It's not super-clean, but does the job.

@snicoll
Copy link
Member Author

snicoll commented Sep 27, 2020

@fabio-grassi-gbs I saw that, that's an interesting approach. I think we'd prefer something more declarative and I've been working on that Friday.

@snicoll snicoll changed the title ConfigurationPropertyNameAliases should not use alias once the value has been bound DataSourceBuilder should only alias a property when the expected DataSource is configured Sep 28, 2020
@snicoll snicoll assigned snicoll and unassigned philwebb Sep 28, 2020
@snicoll snicoll modified the milestones: 2.4.x, 2.4.0-RC1 Sep 28, 2020
@snicoll

This comment has been minimized.

@snicoll
Copy link
Member Author

snicoll commented Oct 7, 2020

Taking that back, that's rather a type safety issue as we have a test to cover that use case. Looking at the hierarchy, I'll settle for OracleDataSource anyway.

@snicoll
Copy link
Member Author

snicoll commented Oct 7, 2020

I've refined things in ef2fee2

snicoll added a commit that referenced this issue Oct 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

3 participants