Affects: spring-context 5.2.3
I'd like to discuss an enhancement to the documentation based on an issue that I encountered while implementing a custom PropertySourceFactory.
Current documentation for the name() method of the annotation reads:
Indicate the name of this property source. If omitted, a name will be generated based on the description of the underlying resource.
I implemented my own factory not worrying about nullable name parameter of method createPropertySource.
When I used properties without explicit I encountered an issue - my resources were overridden instead of merged themselves because of the same name (null) and thus same hashCode (ConfigurationClassParser lines #437 and #475).
This led me to believe there is a bug and the name is not generated as the documentation states.
Yet, it is - but only by DefaultPropertySourceFactory (DefaultPropertySourceFactory#37 and ResourcePropertySource#67).
Suggestion from top of my head:
- update the documentation to state that generation is performed only by the
DefaultPropertySourceFactory - update the contract of the
PropertySourceFactoryto be responsible for the name generation - make the
@PropertySource.name()required && notBlank and skip generation