Skip to content

Commit 5cf801f

Browse files
committed
Polishing.
Add nullability annotation. Return early on null value conversion. See #3633 Original pull request: #3643.
1 parent 2f3fb4a commit 5cf801f

File tree

1 file changed

+6
-1
lines changed
  • spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert

1 file changed

+6
-1
lines changed

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/QueryMapper.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,10 @@ else if (isDocument(value)) {
378378
}
379379
}
380380

381+
if (value == null) {
382+
return null;
383+
}
384+
381385
if (isNestedKeyword(value)) {
382386
return getMappedKeyword(new Keyword((Bson) value), documentField.getPropertyEntity());
383387
}
@@ -635,7 +639,7 @@ public Object convertId(@Nullable Object id, Class<?> targetType) {
635639
* @param candidate
636640
* @return
637641
*/
638-
protected boolean isNestedKeyword(Object candidate) {
642+
protected boolean isNestedKeyword(@Nullable Object candidate) {
639643

640644
if (!(candidate instanceof Document)) {
641645
return false;
@@ -683,6 +687,7 @@ protected boolean isKeyword(String candidate) {
683687
* @param value the actual value. Can be {@literal null}.
684688
* @return the potentially converted target value.
685689
*/
690+
@Nullable
686691
private Object applyFieldTargetTypeHintToValue(Field documentField, @Nullable Object value) {
687692

688693
if (value == null || documentField.getProperty() == null || !documentField.getProperty().hasExplicitWriteTarget()) {

0 commit comments

Comments
 (0)