Affects: 5.0.8
Michael Osipov opened SPR-17221 and commented
Consider the following properties file:
repo.git.snippets.excludes=.git,.gitignore,snippets.ini,README.md
If I simply say:
@Value("${repo.git.snippets.excludes}")
private Path[] snippetsExcludes;
... an array of one element is injected.
In contrast, the following works as expected.
@Value("${repo.git.snippets.excludes}")
private String[] snippetsExcludes_;
It seems like the splitter along with the editors only works for String[]
and not for Path[]
.
See also screenshot from debugger.
Comment From: prateekkapoor
I was facing similar issue with spring wherein multiple files location were not parsed as array of Path. I looked into the code and figured out that value injection for path is is getting processed by PathEditor. Adding a new editor "ArrayPathEditor" similar to PathEdtor which splits the comma seperated values to array of path.
I am able to fix this for my project by adding ArrayPathEditor to the spring code.
Let me know if I can pick this up?
Comment From: sbrannen
Introducing a PathArrayEditor
would be an option, but please note that we do not have a FileArrayEditor
either.
Generally, we recommend the use of Resource[]
since that is supported automatically by the ResourceArrayPropertyEditor
. From those Resource
instances, you can obtain a File
which could be converted to a Path
if you desire.
Does that meet your needs?
Comment From: prateekkapoor
Thanks for replying. Does it mean we won't be supporting Path[]. Instead we should use Resource[] which is already supported by framework.
Comment From: sbrannen
Thanks for replying.
You're welcome.
Does it mean we won't be supporting Path[]. Instead we should use Resource[] which is already supported by framework.
This is currently in the 5.x Backlog for potential future inclusion in the framework.
I've added the "team attention" label to discuss this amongst the team for possible inclusion in 5.3, but in the interim... yes, you should use Resource[]
since it is already supported.
Comment From: snicoll
Reviewing this issue with @jhoeller, we'd prefer String splitting being only supported for String and Resource
arrays.