Skip to content
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

FlexyPoolDataSourceDecorator won't be created if datasource bean in context is interface DataSource #116

Open
bgulowaty opened this issue Nov 24, 2024 · 2 comments

Comments

@bgulowaty
Copy link

given such example definition of data source in application code:

    @Bean
    @Primary
    @ConfigurationProperties(prefix = "database.application.datasource.hikari")
    DataSource applicationDataSource(@Qualifier("applicationDataSourceProperties") DataSourceProperties applicationDataSourceProperties) {
        return applicationDataSourceProperties
                .initializeDataSourceBuilder()
                .driverClassName(applicationDataSourceProperties.getDriverClassName())
                .type(HikariDataSource.class)
                .build();
    }

although its Hikari, but returned as interface DataSource, the FlexyPoolDataSourceDecorator bean won't be created, resulting in datasource not wrapped in Flexy goodies.

This is because one of conditionals on HikariFlexyConfiguration (configuration creating the decorator bean) is HikariDataSource

@gavlyukovskiy
Copy link
Owner

Since flexy pool has specific adapters for each pool, it is required to know the concrete type of datasource to create proper decorator. Are there any reasons you can not use HikariDataSource as the return type?

@bgulowaty
Copy link
Author

I did change it to return specific type in the end, but I had to dig on why doesn't it work out of the box. To improve easiness of use, I think its either worth mentioning it in docs somewhere or autoconfig should be constructed in slightly different way (eg. iterate over all datasources and check their types)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants