@@ -79,12 +79,12 @@ private String getGroupKeyContent(String dataId, String group) throws Exception
79
79
}
80
80
synchronized (this ) {
81
81
if (!groupKeyCache .containsKey (GroupKey .getKey (dataId , group ))) {
82
- String content = nacosConfigManager .getConfigService ().getConfig (dataId , group , 5000 );
82
+ String content = getNacosConfigManager () .getConfigService ().getConfig (dataId , group , 5000 );
83
83
groupKeyCache .put (GroupKey .getKey (dataId , group ), new AtomicReference <>(content ));
84
84
85
85
log .info ("[Nacos Config] Listening config for annotation: dataId={}, group={}" , dataId ,
86
86
group );
87
- nacosConfigManager .getConfigService ().addListener (dataId , group , new AbstractListener () {
87
+ getNacosConfigManager () .getConfigService ().addListener (dataId , group , new AbstractListener () {
88
88
@ Override
89
89
public void receiveConfigInfo (String s ) {
90
90
groupKeyCache .get (GroupKey .getKey (dataId , group )).set (s );
@@ -105,7 +105,8 @@ public String toString() {
105
105
106
106
@ Override
107
107
public Object postProcessBeforeInitialization (Object bean , String beanName ) throws BeansException {
108
- return BeanPostProcessor .super .postProcessBeforeInitialization (bean , beanName );
108
+ BeanPostProcessor .super .postProcessBeforeInitialization (bean , beanName );
109
+ return bean ;
109
110
}
110
111
111
112
@ Override
@@ -223,7 +224,7 @@ public String toString() {
223
224
};
224
225
}
225
226
226
- nacosConfigManager .getConfigService ()
227
+ getNacosConfigManager () .getConfigService ()
227
228
.addListener (dataId , group , listener );
228
229
targetListenerMap .put (refreshTargetKey , listener );
229
230
@@ -270,7 +271,7 @@ public String toString() {
270
271
}
271
272
};
272
273
nacosPropertiesKeyListener .setLastContent (getGroupKeyContent (dataId , group ));
273
- nacosConfigManager .getConfigService ().addListener (dataId , group ,
274
+ getNacosConfigManager () .getConfigService ().addListener (dataId , group ,
274
275
nacosPropertiesKeyListener );
275
276
targetListenerMap .put (refreshTargetKey , nacosPropertiesKeyListener );
276
277
}
@@ -382,7 +383,7 @@ public String toString() {
382
383
};
383
384
}
384
385
385
- nacosConfigManager .getConfigService ().addListener (dataId , group , listener );
386
+ getNacosConfigManager () .getConfigService ().addListener (dataId , group , listener );
386
387
targetListenerMap .put (refreshTargetKey , listener );
387
388
if (annotation .initNotify () && org .springframework .util .StringUtils .hasText (configInfo )) {
388
389
try {
@@ -519,7 +520,7 @@ public String toString() {
519
520
};
520
521
}
521
522
522
- nacosConfigManager .getConfigService ()
523
+ getNacosConfigManager () .getConfigService ()
523
524
.addListener (dataId , group , listener );
524
525
targetListenerMap .put (refreshTargetKey , listener );
525
526
@@ -604,7 +605,7 @@ public String toString() {
604
605
};
605
606
}
606
607
607
- nacosConfigManager .getConfigService ()
608
+ getNacosConfigManager () .getConfigService ()
608
609
.addListener (dataId , group , listener );
609
610
targetListenerMap .put (refreshTargetKey , listener );
610
611
return true ;
@@ -739,7 +740,14 @@ private void handleMethodAnnotation(final Object bean, String beanName, final Me
739
740
@ Override
740
741
public void setApplicationContext (ApplicationContext applicationContext ) throws BeansException {
741
742
this .applicationContext = applicationContext ;
742
- nacosConfigManager = this .applicationContext .getBean (NacosConfigManager .class );
743
+ }
744
+
745
+ private NacosConfigManager getNacosConfigManager () {
746
+ if (this .nacosConfigManager == null ) {
747
+ nacosConfigManager = this .applicationContext .getBean (NacosConfigManager .class );
748
+
749
+ }
750
+ return nacosConfigManager ;
743
751
}
744
752
745
753
private static String [] getNullPropertyNames (Object source ) {
0 commit comments