Skip to content

java.lang.IllegalArgumentException: name in StringToFileConverter #25566

@rsenden

Description

@rsenden

Spring boot version: 2.4.3
Sample code: https://github.com/rsenden/spring-boot-converter-issue

The sample code in the repository listed above runs fine with ./gradlew bootRun, but fails when running java -jar build/libs/demo-0.0.1-SNAPSHOT.jar.

Basically, binding a property to a java.io.File field fails if the property contains a non-existing Windows path, for example C:\Temp\SomeNonExistingFile.txt. This is caused by the org.springframework.boot.convert.StringToFileConverter.convert(String) method calling resource.exists(), which fails when the resource points to a fully qualified Windows-style path when running with org.springframework.boot.loader.LaunchedURLClassLoader.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions