Make sure to initialize PropvertyValueConversions in Converter setup.
Closes #4014 Original pull request: #4015.
This commit is contained in:
committed by
Mark Paluch
parent
198fcbb1a0
commit
705f1b45c8
@@ -166,7 +166,8 @@ public class MongoCustomConversions extends org.springframework.data.convert.Cus
|
||||
private boolean useNativeDriverJavaTimeCodecs = false;
|
||||
private final List<Object> customConverters = new ArrayList<>();
|
||||
|
||||
private PropertyValueConversions propertyValueConversions = new SimplePropertyValueConversions();
|
||||
private PropertyValueConversions propertyValueConversions = PropertyValueConversions.simple(it -> {});
|
||||
private PropertyValueConversions internallyCreatedValueConversion = propertyValueConversions;
|
||||
|
||||
/**
|
||||
* Create a {@link MongoConverterConfigurationAdapter} using the provided {@code converters} and our own codecs for
|
||||
@@ -327,7 +328,7 @@ public class MongoCustomConversions extends org.springframework.data.convert.Cus
|
||||
PropertyValueConversions valueConversions() {
|
||||
|
||||
if (this.propertyValueConversions == null) {
|
||||
this.propertyValueConversions = new SimplePropertyValueConversions();
|
||||
this.propertyValueConversions = PropertyValueConversions.simple(it -> {});
|
||||
}
|
||||
|
||||
return this.propertyValueConversions;
|
||||
@@ -335,6 +336,10 @@ public class MongoCustomConversions extends org.springframework.data.convert.Cus
|
||||
|
||||
ConverterConfiguration createConverterConfiguration() {
|
||||
|
||||
if(isLocallyCreatedPropertyValueConversion() && propertyValueConversions instanceof SimplePropertyValueConversions svc) {
|
||||
svc.init();
|
||||
}
|
||||
|
||||
if (!useNativeDriverJavaTimeCodecs) {
|
||||
return new ConverterConfiguration(STORE_CONVERSIONS, this.customConverters, convertiblePair -> true,
|
||||
this.propertyValueConversions);
|
||||
@@ -391,5 +396,9 @@ public class MongoCustomConversions extends org.springframework.data.convert.Cus
|
||||
return DateToUtcLocalDateTimeConverter.INSTANCE.convert(source).toLocalDate();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isLocallyCreatedPropertyValueConversion() {
|
||||
return propertyValueConversions == internallyCreatedValueConversion;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user