wu-sheng commented on a change in pull request #6860:
URL: https://github.com/apache/skywalking/pull/6860#discussion_r621241410
##########
File path:
oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/RulesReader.java
##########
@@ -257,28 +261,24 @@ private void readFeishuConfig(Rules rules) {
/**
* Read WeLink hook config into {@link WeLinkSettings}
*/
+ @SuppressWarnings("unchecked")
private void readWeLinkConfig(Rules rules) {
- Map welinkConfig = (Map) yamlData.get("welinkHooks");
- if (welinkConfig != null) {
- WeLinkSettings welinkSettings = new WeLinkSettings();
- Object textTemplate = welinkConfig.getOrDefault("textTemplate",
"");
- welinkSettings.setTextTemplate((String) textTemplate);
- List<Map<String, Object>> welinkWebHooks = (List<Map<String,
Object>>) welinkConfig.get("webhooks");
- if (welinkWebHooks != null) {
- welinkWebHooks.forEach(welinkWebhook -> {
- String clientId = (String)
welinkWebhook.getOrDefault("client_id", "");
- String clientSecret = (String)
welinkWebhook.getOrDefault("client_secret", "");
- String accessTokenUrl = (String)
welinkWebhook.getOrDefault("access_token_url", "");
- String messageUrl = (String)
welinkWebhook.getOrDefault("message_url", "");
- String groupIds = (String)
welinkWebhook.getOrDefault("group_ids", "");
- String rebootName = (String)
welinkWebhook.getOrDefault("robot_name", "reboot");
- welinkSettings.getWebhooks()
- .add(new WeLinkSettings.WebHookUrl(clientId,
clientSecret, accessTokenUrl, messageUrl,
-
rebootName, groupIds
- ));
- });
- }
- rules.setWelinks(welinkSettings);
+ Map<String, Object> welinkConfig = (Map<String, Object>)
yamlData.getOrDefault(
+ "welinkHooks",
+ Collections.EMPTY_MAP
Review comment:
Why remove IF but using the EMPTY MAP?
No matter what is the reason, the title of PR doesn't match what you are
doing. Please fix.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]