After upgrading to spring-core 6.1.1 UrlResource("file:test").getFilename() returns null. On older versions 6.0.x i returned "test".

The problem seems to be caused by the fact that older version had field uri set to null and url set, but on 6.1.1 both url and uri is set.

This changes the behavior of getFilename, from getting the filename from url, to failing to get it from uri:

    public String getFilename() {
        if (this.uri != null) {
            // URI path is decoded and has standard separators
            return StringUtils.getFilename(this.uri.getPath());
        }
        else {
            String filename = StringUtils.getFilename(StringUtils.cleanPath(this.url.getPath()));
            return (filename != null ? URLDecoder.decode(filename, StandardCharsets.UTF_8) : null);
        }
    }

Comment From: bushwakko

Doing UrlResource(URL("file:test")) ensures the field uri is set to null, and the getFilename() and you get the same behavior as before.