Skip to content

Commit 1b3d9ed

Browse files
committed
DATACMNS-380 - MappingContext.getPersistentPropertyPath(…) now throws MappingException.
1 parent 0483946 commit 1b3d9ed

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/main/java/org/springframework/data/mapping/context/AbstractMappingContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ private PersistentPropertyPath<P> getPersistentPropertyPath(Iterable<String> par
223223
P persistentProperty = current.getPersistentProperty(segment);
224224

225225
if (persistentProperty == null) {
226-
throw new IllegalArgumentException(String.format("No property %s found on %s!", segment, current.getName()));
226+
throw new MappingException(String.format("No property %s found on %s!", segment, current.getName()));
227227
}
228228

229229
result.add(persistentProperty);

src/test/java/org/springframework/data/mapping/context/AbstractMappingContextUnitTests.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,14 @@ public void returnsPersistentPropertyPathForDotPath() {
185185
assertThat(path.getLeafProperty().getName(), is("name"));
186186
}
187187

188+
/**
189+
* @see DATACMNS-380
190+
*/
191+
@Test(expected = MappingException.class)
192+
public void rejectsInvalidPropertyReferenceWithMappingException() {
193+
context.getPersistentPropertyPath("foo", Sample.class);
194+
}
195+
188196
class Person {
189197
String name;
190198
}

0 commit comments

Comments
 (0)