1717
1818import java .util .ArrayList ;
1919import java .util .List ;
20- import java .util .concurrent .atomic .AtomicBoolean ;
2120
2221import org .springframework .beans .factory .InitializingBean ;
2322import org .springframework .data .convert .PropertyValueConverterFactories .ChainedPropertyValueConverterFactory ;
@@ -40,7 +39,6 @@ public class SimplePropertyValueConversions implements PropertyValueConversions,
4039 private @ Nullable PropertyValueConverterFactory converterFactory ;
4140 private @ Nullable ValueConverterRegistry <?> valueConverterRegistry ;
4241 private boolean converterCacheEnabled = true ;
43- private final AtomicBoolean initialized = new AtomicBoolean (false );
4442
4543 /**
4644 * Set the {@link PropertyValueConverterFactory factory} responsible for creating the actual
@@ -91,23 +89,13 @@ public void setConverterCacheEnabled(boolean converterCacheEnabled) {
9189
9290 @ Override
9391 public boolean hasValueConverter (PersistentProperty <?> property ) {
94-
95- if (!initialized .get ()) {
96- init ();
97- }
98-
9992 return this .converterFactory .getConverter (property ) != null ;
10093 }
10194
10295 @ Nullable
10396 @ Override
10497 public <DV , SV , C extends PersistentProperty <C >, D extends ValueConversionContext <C >> PropertyValueConverter <DV , SV , D > getValueConverter (
10598 C property ) {
106-
107- if (!initialized .get ()) {
108- init ();
109- }
110-
11199 return this .converterFactory .getConverter (property );
112100 }
113101
@@ -116,27 +104,24 @@ public <DV, SV, C extends PersistentProperty<C>, D extends ValueConversionContex
116104 */
117105 public void init () {
118106
119- if (initialized .compareAndSet (false , true )) {
120-
121- List <PropertyValueConverterFactory > factoryList = new ArrayList <>(3 );
107+ List <PropertyValueConverterFactory > factoryList = new ArrayList <>(3 );
122108
123- if (converterFactory != null ) {
124- factoryList .add (converterFactory );
125- } else {
126- factoryList .add (PropertyValueConverterFactory .simple ());
127- }
109+ if (converterFactory != null ) {
110+ factoryList .add (converterFactory );
111+ } else {
112+ factoryList .add (PropertyValueConverterFactory .simple ());
113+ }
128114
129- if ((valueConverterRegistry != null ) && !valueConverterRegistry .isEmpty ()) {
130- factoryList .add (PropertyValueConverterFactory .configuredInstance (valueConverterRegistry ));
131- }
115+ if ((valueConverterRegistry != null ) && !valueConverterRegistry .isEmpty ()) {
116+ factoryList .add (PropertyValueConverterFactory .configuredInstance (valueConverterRegistry ));
117+ }
132118
133- PropertyValueConverterFactory targetFactory = factoryList .size () > 1
134- ? PropertyValueConverterFactory .chained (factoryList )
135- : factoryList .iterator ().next ();
119+ PropertyValueConverterFactory targetFactory = factoryList .size () > 1
120+ ? PropertyValueConverterFactory .chained (factoryList )
121+ : factoryList .iterator ().next ();
136122
137- this .converterFactory = converterCacheEnabled ? PropertyValueConverterFactory .caching (targetFactory )
138- : targetFactory ;
139- }
123+ this .converterFactory = converterCacheEnabled ? PropertyValueConverterFactory .caching (targetFactory )
124+ : targetFactory ;
140125 }
141126
142127 @ Override
0 commit comments