1818
1919import group .rxcloud .cloudruntimes .domain .core .configuration .SubConfigurationResp ;
2020import group .rxcloud .cloudruntimes .utils .TypeRef ;
21+ import org .slf4j .Logger ;
22+ import org .slf4j .LoggerFactory ;
2123import reactor .core .publisher .Flux ;
2224
2325import java .util .Collections ;
2426import java .util .HashMap ;
2527import java .util .Map ;
26- import java .util .Properties ;
2728import java .util .concurrent .atomic .AtomicReferenceArray ;
2829
2930/**
3637@ Deprecated
3738public class MergedPropertiesConfig {
3839
40+ private static final Logger log = LoggerFactory .getLogger (MergedPropertiesConfig .class );
41+
3942 private final String fileName ;
4043
41- private final AtomicReferenceArray <Properties > properties ;
44+ private final AtomicReferenceArray <Map > properties ;
4245
4346 private final Object lock = new Object ();
4447
@@ -50,7 +53,12 @@ public MergedPropertiesConfig(String fileName, String... appIds) {
5053 merged = new HashMap <>();
5154 Mixer .configurationHooksNullable ().ifPresent (hooks -> {
5255 for (int i = 0 ; i < appIds .length ; i ++) {
53- subscribeConfigurationByAppId (hooks , appIds [i ], i );
56+ try {
57+ subscribeConfigurationByAppId (hooks , appIds [i ], i );
58+ } catch (Throwable throwable ) {
59+ log .warn ("Fail to subscribe config for app id " + appIds [i ] + ", index " + i , throwable );
60+ }
61+
5462 }
5563 });
5664 }
@@ -70,14 +78,14 @@ public Map<String, String> getMerged() {
7078 private void subscribeConfigurationByAppId (ConfigurationHooks configurationHooks , String appId , int index ) {
7179 String storeName = configurationHooks .registryStoreNames ().get (0 );
7280
73- Flux <SubConfigurationResp <Properties >> configFlux = configurationHooks .subscribeConfiguration (
81+ Flux <SubConfigurationResp <Map >> configFlux = configurationHooks .subscribeConfiguration (
7482 storeName ,
7583 appId ,
7684 Collections .singletonList (fileName ),
7785 null ,
7886 "" ,
7987 "" ,
80- TypeRef .get (Properties .class ));
88+ TypeRef .get (Map .class ));
8189
8290 // FIXME: 2021/12/3 random callback?
8391 configFlux .subscribe (resp -> {
@@ -90,7 +98,7 @@ private void subscribeConfigurationByAppId(ConfigurationHooks configurationHooks
9098
9199 Map <String , String > merged = new HashMap <>();
92100 for (int i = 0 ; i < properties .length (); i ++) {
93- Properties item = properties .get (i );
101+ Map item = properties .get (i );
94102 if (item != null ) {
95103 item .forEach ((k , v ) -> merged .putIfAbsent (String .valueOf (k ), String .valueOf (v )));
96104 }
0 commit comments