Skip to content

Commit f6db089

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

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
@@ -444,6 +444,10 @@ else if (isDocument(value)) {
444444
}
445445
}
446446

447+
if (value == null) {
448+
return null;
449+
}
450+
447451
if (isNestedKeyword(value)) {
448452
return getMappedKeyword(new Keyword((Bson) value), documentField.getPropertyEntity());
449453
}
@@ -706,7 +710,7 @@ public Object convertId(@Nullable Object id, Class<?> targetType) {
706710
* @param candidate
707711
* @return
708712
*/
709-
protected boolean isNestedKeyword(Object candidate) {
713+
protected boolean isNestedKeyword(@Nullable Object candidate) {
710714

711715
if (!(candidate instanceof Document)) {
712716
return false;
@@ -754,6 +758,7 @@ protected boolean isKeyword(String candidate) {
754758
* @param value the actual value. Can be {@literal null}.
755759
* @return the potentially converted target value.
756760
*/
761+
@Nullable
757762
private Object applyFieldTargetTypeHintToValue(Field documentField, @Nullable Object value) {
758763

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

0 commit comments

Comments
 (0)