java.nio.file.Path support in FileSystemResource (with regular createRelative behavior, superseding PathResource) [SPR-16833] #21373
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
type: enhancement
A general enhancement
Milestone
Robert Saenger opened SPR-16833 and commented
org.springframework.core.io.PathResource#createRelative(String) doesn't work correctly if the underlying path refers to a file and not to a directory. The problem of the implementation is, that it doesn't properly distinguish between files an directories. In both cases the implementation returns a Resource whose path is simply extended by the given relative path. This is correct if the path points to a directory but invalid if the path points to a file, e.g. <path-to-file>/<relative path> is always invalid it should be <path-to-file-parent>/<relative-path>.
Suggested fix ist to change the implementation as follows:
Since the implementation prevents access to the instance variable path, it is not possible to fix the problem via inheritance and overriding the method. Thus as workaround the entire class may be copied and modified as described above.
Affects: 5.0.2
Issue Links:
Referenced from: commits 38f9a7b
The text was updated successfully, but these errors were encountered: