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

Ignore unbindable DataSource properties #43988

Closed
mhalbritter opened this issue Jan 28, 2025 · 5 comments
Closed

Ignore unbindable DataSource properties #43988

mhalbritter opened this issue Jan 28, 2025 · 5 comments
Assignees
Labels
type: enhancement A general enhancement
Milestone

Comments

@mhalbritter
Copy link
Contributor

As we now have a way to ignore properties, we should review the @ConfigurationProperties annotated @Bean methods if we want to ignore properties.

Here are the prefixes I found which come from a @ConfigurationProperties annotated method:

  • spring.datasource.dbcp2
  • spring.datasource.hikari
  • spring.datasource.oracleucp
  • spring.datasource.tomcat
  • spring.groovy.template.configuration
@mhalbritter mhalbritter added the type: task A general task label Jan 28, 2025
@mhalbritter mhalbritter added this to the 3.5.x milestone Jan 28, 2025
@wilkinsona
Copy link
Member

That matches up with these exclusions:

tasks.named("checkSpringConfigurationMetadata").configure {
exclusions = [
"spring.datasource.dbcp2.*",
"spring.datasource.hikari.*",
"spring.datasource.oracleucp.*",
"spring.datasource.tomcat.*",
"spring.groovy.template.configuration.*"
]

Hopefully we should be able to remove them once the ignored properties are in place.

@mhalbritter
Copy link
Contributor Author

mhalbritter commented Jan 29, 2025

I've played around with that here: https://github.com/mhalbritter/spring-boot/tree/mh/43988-review-configurationproperties-annotated-bean-methods-for-ignored-properties

I've added all the Hikari properties to the additional-spring-configuration-metadata.json either in the properties section (only added name and a dummy description) or added the non-bindable properties to the ignored array. Then I removed spring.datasource.hikari.* from the checkSpringConfigurationMetadata configuration.

Antora creates a row for every hikari property if the hikari prefix is removed from org.springframework.boot.build.context.properties.DocumentConfigurationProperties#dataPrefixes.

For the description: I've copied the JavaDoc description from HikariDataSource into the additional-spring-configuration-metadata.json. I guess that's the way to go for the remaining ones, too?

@wilkinsona
Copy link
Member

Sorry, I was probably overly optimistic about being able to get rid of those exclusions. For this issue, I think we should focus on ignoring the properties that it does not make sense to expose in the metadata. We can address the descriptions separately if we decide we want to tackle that too.

The properties you've ignored look good to me. I wondered about keeping the following:

  • spring.datasource.hikari.driver-class-name
  • spring.datasource.hikari.jdbc-uri
  • spring.datasource.hikari.password
  • spring.datasource.hikari.username

However, I don't think it's necessary as they all have equivalent spring.datasource.* properties that are preferred. @snicoll's more familiar than I am with the subtleties here with things like jdbc-url vs url. Does this sound right to you, Stephane?

I also noticed that we have a couple of groups in the metadata that don't make sense:

  • spring.datasource.hikari.health-check-registry
  • spring.datasource.hikari.metric-registry

There are no properties in either of these groups. This looks like a bug in the annotation processor to me as I don't think it should create an empty group. We can tackle that in a separate issue.

@mhalbritter
Copy link
Contributor Author

mhalbritter commented Jan 29, 2025

// Edit: Ah nvm, i misread the code and the JavaDoc of the superclass class clarifies that it doesn't apply for PropertiesJdbcConnectionDetails. Ignore the comment :)

Thanks Andy. We have a HikariJdbcConnectionDetailsBeanPostProcessor in place which post-processes HikariDataSource beans and overrides jdbcUrl, username, password and driverClassName with values coming from the JdbcConnectionDetails. Which most likely will be a PropertiesJdbcConnectionDetails and would then use the spring.datasource.* values. That's the reason I included them in the ignore list, because they don't have an effect anyway.

@mhalbritter mhalbritter changed the title Review @ConfigurationProperties annotated @Bean methods for ignored properties Ignore unbindable properties Jan 31, 2025
@mhalbritter mhalbritter added type: enhancement A general enhancement and removed type: task A general task labels Jan 31, 2025
@mhalbritter mhalbritter self-assigned this Jan 31, 2025
@mhalbritter mhalbritter modified the milestones: 3.5.x, 3.5.0-M2 Jan 31, 2025
@mhalbritter
Copy link
Contributor Author

mhalbritter commented Jan 31, 2025

I've now added exclusions for all unbindable properties for dbcp2, hikari, oracleucp and tomcat. All properties from spring.groovy.template.configuration are bindable, so no ignores are needed.

@mhalbritter mhalbritter changed the title Ignore unbindable properties Ignore unbindable DataSource properties Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants