mirror of
https://gitee.com/mirrors/Spring-Cloud-Alibaba.git
synced 2021-06-26 13:25:11 +08:00
format code and change logger to log
This commit is contained in:
parent
e6c7b10b79
commit
f96869e1d2
@ -33,7 +33,7 @@ import java.util.*;
|
|||||||
*/
|
*/
|
||||||
class AcmPropertySourceBuilder {
|
class AcmPropertySourceBuilder {
|
||||||
|
|
||||||
private Logger logger = LoggerFactory.getLogger(AcmPropertySourceBuilder.class);
|
private Logger log = LoggerFactory.getLogger(AcmPropertySourceBuilder.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 传入 ACM 的 DataId 和 groupID,获取到解析后的 AcmProperty 对象
|
* 传入 ACM 的 DataId 和 groupID,获取到解析后的 AcmProperty 对象
|
||||||
@ -59,20 +59,23 @@ class AcmPropertySourceBuilder {
|
|||||||
}
|
}
|
||||||
if (dataId.endsWith(".properties")) {
|
if (dataId.endsWith(".properties")) {
|
||||||
Properties properties = new Properties();
|
Properties properties = new Properties();
|
||||||
logger.info(String.format("Loading acm data, dataId: '%s', group: '%s'",
|
log.info(String.format("Loading acm data, dataId: '%s', group: '%s'",
|
||||||
dataId, diamondGroup));
|
dataId, diamondGroup));
|
||||||
properties.load(new StringReader(data));
|
properties.load(new StringReader(data));
|
||||||
return properties;
|
return properties;
|
||||||
} else if (dataId.endsWith(".yaml") || dataId.endsWith(".yml")) {
|
}
|
||||||
|
else if (dataId.endsWith(".yaml") || dataId.endsWith(".yml")) {
|
||||||
YamlPropertiesFactoryBean yamlFactory = new YamlPropertiesFactoryBean();
|
YamlPropertiesFactoryBean yamlFactory = new YamlPropertiesFactoryBean();
|
||||||
yamlFactory.setResources(new ByteArrayResource(data.getBytes()));
|
yamlFactory.setResources(new ByteArrayResource(data.getBytes()));
|
||||||
return yamlFactory.getObject();
|
return yamlFactory.getObject();
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
}
|
||||||
|
catch (Exception e) {
|
||||||
if (e instanceof ConfigException) {
|
if (e instanceof ConfigException) {
|
||||||
logger.error("DIAMOND-100500:" + dataId + ", " + e.toString(), e);
|
log.error("DIAMOND-100500:" + dataId + ", " + e.toString(), e);
|
||||||
} else {
|
}
|
||||||
logger.error("DIAMOND-100500:" + dataId, e);
|
else {
|
||||||
|
log.error("DIAMOND-100500:" + dataId, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -81,13 +84,14 @@ class AcmPropertySourceBuilder {
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private Map<String, Object> toMap(Properties properties) {
|
private Map<String, Object> toMap(Properties properties) {
|
||||||
Map<String, Object> result = new HashMap<>();
|
Map<String, Object> result = new HashMap<>();
|
||||||
Enumeration<String> keys = (Enumeration<String>)properties.propertyNames();
|
Enumeration<String> keys = (Enumeration<String>) properties.propertyNames();
|
||||||
while (keys.hasMoreElements()) {
|
while (keys.hasMoreElements()) {
|
||||||
String key = keys.nextElement();
|
String key = keys.nextElement();
|
||||||
Object value = properties.getProperty(key);
|
Object value = properties.getProperty(key);
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
result.put(key, ((String)value).trim());
|
result.put(key, ((String) value).trim());
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
result.put(key, null);
|
result.put(key, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,8 @@ public class AcmHealthIndicator extends AbstractHealthIndicator {
|
|||||||
builder.down().withDetail(String.format("dataId: '%s', group: '%s'",
|
builder.down().withDetail(String.format("dataId: '%s', group: '%s'",
|
||||||
dataId, acmProperties.getGroup()), "config is empty");
|
dataId, acmProperties.getGroup()), "config is empty");
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
}
|
||||||
|
catch (Exception e) {
|
||||||
builder.down().withDetail(String.format("dataId: '%s', group: '%s'",
|
builder.down().withDetail(String.format("dataId: '%s', group: '%s'",
|
||||||
dataId, acmProperties.getGroup()), e.getMessage());
|
dataId, acmProperties.getGroup()), e.getMessage());
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ import com.alibaba.edas.acm.listener.ConfigChangeListener;
|
|||||||
public class AcmContextRefresher
|
public class AcmContextRefresher
|
||||||
implements ApplicationListener<ApplicationReadyEvent>, ApplicationContextAware {
|
implements ApplicationListener<ApplicationReadyEvent>, ApplicationContextAware {
|
||||||
|
|
||||||
private Logger logger = LoggerFactory.getLogger(AcmContextRefresher.class);
|
private Logger log = LoggerFactory.getLogger(AcmContextRefresher.class);
|
||||||
|
|
||||||
private final ContextRefresher contextRefresher;
|
private final ContextRefresher contextRefresher;
|
||||||
|
|
||||||
@ -103,7 +103,7 @@ public class AcmContextRefresher
|
|||||||
}
|
}
|
||||||
catch (NoSuchAlgorithmException
|
catch (NoSuchAlgorithmException
|
||||||
| UnsupportedEncodingException e) {
|
| UnsupportedEncodingException e) {
|
||||||
logger.warn("unable to get md5 for dataId: " + dataId, e);
|
log.warn("unable to get md5 for dataId: " + dataId, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
refreshHistory.add(dataId, md5);
|
refreshHistory.add(dataId, md5);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user