@@ -67,24 +67,10 @@ public synchronized void handleEvent(ConfigurationChangedEvent event) {
67
67
processConfigPropsClass (toRefreshProps , key );
68
68
processValueField (key , entry .getValue ());
69
69
}
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 );
82
71
log .info ("config changes of {} have been processed" , event .getSource ());
83
72
} catch (Exception ex ) {
84
73
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
- }
88
74
}
89
75
}
90
76
@@ -166,6 +152,21 @@ private void convertAndBindFieldValue(Object val, ValueBeanFieldBinder binder, O
166
152
}
167
153
}
168
154
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
+
169
170
private void removeMissingPropsMapFields (Map <Object , Object > diff , Object rootBean , String prefix ) throws IllegalAccessException {
170
171
for (Map .Entry <Object , Object > entry : diff .entrySet ()) {
171
172
Object propKey = entry .getKey ();
0 commit comments