This repository was archived by the owner on Feb 23, 2023. It is now read-only.
Fix factory name with spaces in "spring.factories" #1421
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In
spring.factories
, when there is a space after comma delimiter, it fails to resolve the class and does not create the correspondingSpringFactory
.The following
spring.factories
only pick upFactoryFoo
because there is a space after the comma.com.example.MyFactory =\ com.example.FactoryFoo, com.example.FactoryBar
com.example.MyFactory =\ com.example.FactoryFoo, \ com.example.FactoryBar
This is because when this entry is loaded and split to an array, it is interpreted as
["com.example.FactoryFoo", " com.example.FactoryBar"]
. The second entry contains a space in front. So that when it createsSpringFactory
inSpringFactoriesContributor
it cannot resolve the target class and it is skipped.In Spring Framework, it applies
trim()
to each entry value.https://github.com/spring-projects/spring-framework/blob/8dd385b440cb2e432ce7151be08d313982d3b00c/spring-core/src/main/java/org/springframework/core/io/support/SpringFactoriesLoader.java#L153
This PR adds
trim()
while processing thespring.factories
inSpringFactoriesContributor
; so that it properly recognizes the entry with spaces.