spring-cloud / spring-cloud/spring-cloud-commons

Possibly misleading warning about HikariDataSource not being refreshable

Open Beginner friendly
#1,708 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

waiting-for-triage
Dominant language
Java
Stars
751
Forks
744
Avg merge
1d 14h
Merged PRs (30d)
9

Description

Description

There is the following warning on the page Spring Cloud Context: Application Context Services:

If you have a DataSource bean that is a HikariDataSource, it can not be refreshed. It is the default value for spring.cloud.refresh.never-refreshable. Choose a different DataSource implementation if you need it to be refreshed.

This statement may be misleading because it appears in the section describing @RefreshScope. As far as I understand, there is nothing that prevents users from annotating a HikariDataSource bean with @RefreshScope, since the underlying target bean is recreated when the refresh scope is refreshed.

It is probably true that relying on @ConfigurationProperties rebinding for a HikariDataSource is not a good idea. That behavior is explicitly disabled through the spring.cloud.refresh.never-refreshable property, which includes HikariDataSource by default. However, looking at the implementation of ConfigurationPropertiesRebinder#getNeverRefreshable, this property only affects configuration property rebinding and is unrelated to beans managed by @RefreshScope.

I also don't understand why HikariDataSource is singled out here. Pooled DataSource implementations are generally fairly complex objects, and relying on configuration property rebinding alone is probably too simplistic. If that's the concern, it would seem to apply equally to other pooled DataSource implementations (for example, Tomcat JDBC Pool), not just HikariDataSource.

Suggestion

Update the documentation as follows:

  1. Move the note about HikariDataSource from the Refresh Scope section to the Environment Changes section.
  2. Generalize the note to explain that relying on configuration property rebinding for pooled DataSource implementations may not be appropriate in general, rather than singling out HikariDataSource.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked Spring Cloud Context: Application Context Services page and read ConfigurationPropertiesRebinder#getNeverRefreshable in spring-cloud-context/src/main/java/org/springframework/cloud/context/properties/ConfigurationPropertiesRebinder.java. Locate the page source, move the pooled DataSource note to Environment Changes, generalize its wording, and verify the rendered documentation.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring, spring-boot
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.