Browse Source

Fixes NPE in PersistentPropertyPathExtension.equals.

Closes #1164
pull/1166/head
Jens Schauder 4 years ago
parent
commit
e84a34a507
No known key found for this signature in database
GPG Key ID: 45CC872F17423DBF
  1. 20
      spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/PersistentPropertyPathExtensionUnitTests.java
  2. 2
      spring-data-relational/src/main/java/org/springframework/data/relational/core/mapping/PersistentPropertyPathExtension.java

20
spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/PersistentPropertyPathExtensionUnitTests.java

@ -200,6 +200,26 @@ public class PersistentPropertyPathExtensionUnitTests { @@ -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);
}

2
spring-data-relational/src/main/java/org/springframework/data/relational/core/mapping/PersistentPropertyPathExtension.java

@ -442,7 +442,7 @@ public class PersistentPropertyPathExtension { @@ -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

Loading…
Cancel
Save