Skip to content

Commit a481636

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

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

+6-1
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,10 @@ else if (isDocument(value)) {
445445
}
446446
}
447447

448+
if (value == null) {
449+
return null;
450+
}
451+
448452
if (isNestedKeyword(value)) {
449453
return getMappedKeyword(new Keyword((Bson) value), documentField.getPropertyEntity());
450454
}
@@ -711,7 +715,7 @@ public Object convertId(@Nullable Object id, Class<?> targetType) {
711715
* @param candidate
712716
* @return
713717
*/
714-
protected boolean isNestedKeyword(Object candidate) {
718+
protected boolean isNestedKeyword(@Nullable Object candidate) {
715719

716720
if (!(candidate instanceof Document)) {
717721
return false;
@@ -759,6 +763,7 @@ protected boolean isKeyword(String candidate) {
759763
* @param value the actual value. Can be {@literal null}.
760764
* @return the potentially converted target value.
761765
*/
766+
@Nullable
762767
private Object applyFieldTargetTypeHintToValue(Field documentField, @Nullable Object value) {
763768

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

0 commit comments

Comments
 (0)