@@ -67,24 +67,10 @@ public synchronized void handleEvent(ConfigurationChangedEvent event) {
6767 processConfigPropsClass (toRefreshProps , key );
6868 processValueField (key , entry .getValue ());
6969 }
70- for (Map .Entry <String , ValueBeanFieldBinder > entry : toRefreshProps .entrySet ()) {
71- String beanName = entry .getKey ();
72- ValueBeanFieldBinder binder = entry .getValue ();
73- Object bean = binder .getBeanRef ().get ();
74- if (bean != null ) {
75- processor .postProcessBeforeInitialization (bean , beanName );
76- // AggregateBinder - MapBinder will merge properties while binding
77- // need to check deleted keys and remove from map fields
78- removeMissingPropsMapFields (diff , bean , binder .getExpr ());
79- log .debug ("changes detected, re-bind ConfigurationProperties bean: {}" , beanName );
80- }
81- }
70+ rebindRelatedConfigurationPropsBeans (diff , toRefreshProps );
8271 log .info ("config changes of {} have been processed" , event .getSource ());
8372 } catch (Exception ex ) {
8473 log .warn ("config changes of {} can not be processed, error:" , event .getSource (), ex );
85- if (log .isDebugEnabled ()) {
86- log .error ("error detail is:" , ex );
87- }
8874 }
8975 }
9076
@@ -166,6 +152,21 @@ private void convertAndBindFieldValue(Object val, ValueBeanFieldBinder binder, O
166152 }
167153 }
168154
155+ private void rebindRelatedConfigurationPropsBeans (Map <Object , Object > diff , Map <String , ValueBeanFieldBinder > toRefreshProps ) throws IllegalAccessException {
156+ for (Map .Entry <String , ValueBeanFieldBinder > entry : toRefreshProps .entrySet ()) {
157+ String beanName = entry .getKey ();
158+ ValueBeanFieldBinder binder = entry .getValue ();
159+ Object bean = binder .getBeanRef ().get ();
160+ if (bean != null ) {
161+ processor .postProcessBeforeInitialization (bean , beanName );
162+ // AggregateBinder - MapBinder will merge properties while binding
163+ // need to check deleted keys and remove from map fields
164+ removeMissingPropsMapFields (diff , bean , binder .getExpr ());
165+ log .debug ("changes detected, re-bind ConfigurationProperties bean: {}" , beanName );
166+ }
167+ }
168+ }
169+
169170 private void removeMissingPropsMapFields (Map <Object , Object > diff , Object rootBean , String prefix ) throws IllegalAccessException {
170171 for (Map .Entry <Object , Object > entry : diff .entrySet ()) {
171172 Object propKey = entry .getKey ();
0 commit comments