Skip to content

Path objects are incompatible with classpath resource resolution on Windows #2143

@frouene

Description

@frouene

Description

When constructing a locationPattern for Spring's PathMatchingResourcePatternResolver in SysONLibraryLoader using a Path object (e.g., Paths.get("name/library")), the resulting path string contains backslashes (\) on Windows. This breaks resource resolution in JAR files and the classpath, as JARs and Spring's resource loaders only accept forward slashes (/) for paths.

Current Behavior

  • On Windows, Paths.get("name", "library").toString() returns name\library.
  • When used in a locationPattern like classpath*:name\library/*.json, Spring fails to find the resource because:
    • JAR files internally use / as separators.
    • Spring's PathMatchingResourcePatternResolver expects / in classpath patterns.

Expected Behavior

The locationPattern should always use / as a separator, regardless of the operating system, to ensure compatibility with:

  • JAR files.
  • Spring's resource resolution.
  • Cross-platform deployments.

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions