Skip to content

PathMatchingResourcePatternResolver duplicates module/file resources #29934

@Del-Tab

Description

@Del-Tab

Affects: <6.0.4>

When upgrading from spring-core-5.3.24.jar to spring-core-6.0.4.jar (spring-boot 2 to 3 upgrade)

Our test uses persistence.xml descriptions for persistence units. The test fails for a duplicated persistence unit.

main cause found in debugger:
the set created at org.springframework.core.io.support.PathMatchingResourcePatternResolver#getResources line 325 with one element returned by findAllModulePathResources(locationPatternWithoutPrefix) :

  • a org.springframework.core.io.FileSystemResource whose Path (its hash source material) is /C:/SomePath/target/test-classes/META-INF/persistence.xml

then the set is completed line 332 by the result of findAllClassPathResources(locationPatternWithoutPrefix), which returns the same resource as the old version (spring-core-5.3.24):

  • an org.springframework.core.io.UrlResource whose getCleanedUrl() (its hash source material) is file:/C:/SomePath/target/test-classes/META-INF/persistence.xml (notice the file: prefix)

The found resources are the same file resource in 2 different Java structures, but their hash being solved differently, they both are added to the set, and therefore this resource conflicts with itself.

Consequence:
the method org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager#preparePersistenceUnitInfos fails the test at line 470 because the persistence units are duplicated (but they come from the same source).

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: regressionA bug that is also a regression

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions