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);
}