Fixes NPE in PersistentPropertyPathExtension.equals.

Closes #1164
This commit is contained in:
Jens Schauder
2022-02-11 09:08:00 +01:00
parent f0ea903e72
commit d377b0f0ba
2 changed files with 21 additions and 1 deletions

View File

@@ -200,6 +200,26 @@ public class PersistentPropertyPathExtensionUnitTests {
});
}
@Test // GH--1164
void equalsWorks() {
PersistentPropertyPathExtension root1 = extPath(entity);
PersistentPropertyPathExtension root2 = extPath(entity);
PersistentPropertyPathExtension path1 = extPath("withId");
PersistentPropertyPathExtension path2 = extPath("withId");
assertSoftly(softly -> {
softly.assertThat(root1).describedAs("root is equal to self").isEqualTo(root1);
softly.assertThat(root2).describedAs("root is equal to identical root").isEqualTo(root1);
softly.assertThat(path1).describedAs("path is equal to self").isEqualTo(path1);
softly.assertThat(path2).describedAs("path is equal to identical path").isEqualTo(path1);
softly.assertThat(path1).describedAs("path is not equal to other path").isNotEqualTo(extPath("entityId"));
softly.assertThat(root1).describedAs("root is not equal to path").isNotEqualTo(path1);
softly.assertThat(path1).describedAs("path is not equal to root").isNotEqualTo(root1);
});
}
private PersistentPropertyPathExtension extPath(RelationalPersistentEntity<?> entity) {
return new PersistentPropertyPathExtension(context, entity);
}

View File

@@ -442,7 +442,7 @@ public class PersistentPropertyPathExtension {
if (o == null || getClass() != o.getClass()) return false;
PersistentPropertyPathExtension that = (PersistentPropertyPathExtension) o;
return entity.equals(that.entity) &&
path.equals(that.path);
Objects.equals(path, that.path);
}
@Override