Make sure to initialize PropvertyValueConversions in Converter setup.
Closes #4014 Original pull request: #4015.
This commit is contained in:
committed by
Mark Paluch
parent
350acf66bc
commit
7ab2428c64
@@ -156,7 +156,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
|
||||
@@ -317,7 +318,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;
|
||||
@@ -325,6 +326,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);
|
||||
@@ -381,5 +386,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