Skip to content

ClassPathResources with same absolute path and same ClassLoader should be equal #29263

@sbrannen

Description

@sbrannen

Currently, if two ClassPathResource instances are constructed differently (one with an absolute path and one with a path relative to a Class) but have the same absolute path and the same ClassLoader, they are effectively equal, but ClassPathResource#equals returns false.

For example, the following test fails.

@Test
void resourcesWithEquivalentAbsolutePathsAreEqual() {
	Resource resource1 = new ClassPathResource("Resource.class", getClass());
	Resource resource2 = new ClassPathResource("org/springframework/core/io/Resource.class", getClass().getClassLoader());
	assertThat(resource2).isEqualTo(resource1);
}

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions