PathMatchingResourcePatternResolver inconsistently throws IOException in case of non-existing resources [SPR-7365] #12023
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
type: enhancement
A general enhancement
Milestone
Christian Cwienk opened SPR-7365 and commented
PathMatchingResourcePatternResolver behaves inconsistently (and imho in an unintuitive manner) as to the respect of throwing IOExceptions when resolving a given ant-style path pattern to concrete resources (tested with local filesystem):
In cases where no files are found (existing directory with no matching files), an empty array of Resource is returned (which is intuitive). If however, a part of the pathPattern does not exist (i.e. a directory does not exist), an IOException is being thrown unless the non-existing directory is specified after the first occurence of a wildcard, in which case an empty result array is returned.
imho, this is unintuitive and inconsistent for two reasons:
I'd expect a path pattern matcher to try match applying a best-effort strategy; in case nothing can be matched, I'd regard that as a normal outcome and would expect to get an empty result-array (which in some but not all cases actually happens)
Provided throwing an IOException in case part of the specified path does not exist made sense; then I'd expect this behaviour to be also applied for path parts after occurrences of wildcards (which is not the case).
I've created a possible solution for this issue by subclassing the class in question (see attached files). However I'd very much appreciate it if this change could be incorporated into a future release of the Spring framework.
Best Regards,
Christian
Affects: 2.5.6
Attachments:
The text was updated successfully, but these errors were encountered: