Skip to content

Commit 852a4ec

Browse files
committed
Polishing.
Refine default conversions creation. See #4014 Original pull request: #4015.
1 parent 7ab2428 commit 852a4ec

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

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

+8-7
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@ public static class MongoConverterConfigurationAdapter {
156156
private boolean useNativeDriverJavaTimeCodecs = false;
157157
private final List<Object> customConverters = new ArrayList<>();
158158

159-
private PropertyValueConversions propertyValueConversions = PropertyValueConversions.simple(it -> {});
160-
private PropertyValueConversions internallyCreatedValueConversion = propertyValueConversions;
159+
private final PropertyValueConversions internalValueConversion = PropertyValueConversions.simple(it -> {});
160+
private PropertyValueConversions propertyValueConversions = internalValueConversion;
161161

162162
/**
163163
* Create a {@link MongoConverterConfigurationAdapter} using the provided {@code converters} and our own codecs for
@@ -178,7 +178,7 @@ public static MongoConverterConfigurationAdapter from(List<?> converters) {
178178
}
179179

180180
/**
181-
* Set whether or not to use the native MongoDB Java Driver {@link org.bson.codecs.Codec codes} for
181+
* Set whether to or not to use the native MongoDB Java Driver {@link org.bson.codecs.Codec codes} for
182182
* {@link org.bson.codecs.jsr310.LocalDateCodec LocalDate}, {@link org.bson.codecs.jsr310.LocalTimeCodec LocalTime}
183183
* and {@link org.bson.codecs.jsr310.LocalDateTimeCodec LocalDateTime} using a {@link ZoneOffset#UTC}.
184184
*
@@ -318,15 +318,16 @@ public MongoConverterConfigurationAdapter setPropertyValueConversions(PropertyVa
318318
PropertyValueConversions valueConversions() {
319319

320320
if (this.propertyValueConversions == null) {
321-
this.propertyValueConversions = PropertyValueConversions.simple(it -> {});
321+
this.propertyValueConversions = internalValueConversion;
322322
}
323323

324324
return this.propertyValueConversions;
325325
}
326326

327327
ConverterConfiguration createConverterConfiguration() {
328328

329-
if(isLocallyCreatedPropertyValueConversion() && propertyValueConversions instanceof SimplePropertyValueConversions svc) {
329+
if (hasDefaultPropertyValueConversions()
330+
&& propertyValueConversions instanceof SimplePropertyValueConversions svc) {
330331
svc.init();
331332
}
332333

@@ -387,8 +388,8 @@ public LocalDate convert(Date source) {
387388
}
388389
}
389390

390-
private boolean isLocallyCreatedPropertyValueConversion() {
391-
return propertyValueConversions == internallyCreatedValueConversion;
391+
private boolean hasDefaultPropertyValueConversions() {
392+
return propertyValueConversions == internalValueConversion;
392393
}
393394
}
394395
}

0 commit comments

Comments
 (0)