From 82e61945af5cf7851a63d3fdf6f130819128c31c Mon Sep 17 00:00:00 2001 From: fangjian0423 Date: Mon, 17 Jun 2019 10:32:00 +0800 Subject: [PATCH] close #707 --- .../custom/SentinelDataSourceHandler.java | 51 ------------------- 1 file changed, 51 deletions(-) diff --git a/spring-cloud-alibaba-sentinel/src/main/java/org/springframework/cloud/alibaba/sentinel/custom/SentinelDataSourceHandler.java b/spring-cloud-alibaba-sentinel/src/main/java/org/springframework/cloud/alibaba/sentinel/custom/SentinelDataSourceHandler.java index 6b5fce5f2..f1dd0cfc1 100644 --- a/spring-cloud-alibaba-sentinel/src/main/java/org/springframework/cloud/alibaba/sentinel/custom/SentinelDataSourceHandler.java +++ b/spring-cloud-alibaba-sentinel/src/main/java/org/springframework/cloud/alibaba/sentinel/custom/SentinelDataSourceHandler.java @@ -2,12 +2,10 @@ package org.springframework.cloud.alibaba.sentinel.custom; import java.lang.reflect.Field; import java.util.Arrays; -import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Optional; -import java.util.Set; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -19,7 +17,6 @@ import org.springframework.cloud.alibaba.sentinel.datasource.config.AbstractData import org.springframework.cloud.alibaba.sentinel.datasource.converter.JsonConverter; import org.springframework.cloud.alibaba.sentinel.datasource.converter.XmlConverter; import org.springframework.core.env.Environment; -import org.springframework.util.CollectionUtils; import org.springframework.util.ReflectionUtils; import org.springframework.util.StringUtils; @@ -187,56 +184,8 @@ public class SentinelDataSourceHandler implements SmartInitializingSingleton { AbstractDataSource newDataSource = (AbstractDataSource) this.beanFactory .getBean(dataSourceName); - logAndCheckRuleType(newDataSource, dataSourceName, - dataSourceProperties.getRuleType().getClazz()); - // register property in RuleManager dataSourceProperties.postRegister(newDataSource); } - private void logAndCheckRuleType(AbstractDataSource dataSource, String dataSourceName, - Class ruleClass) { - Object ruleConfig; - try { - ruleConfig = dataSource.loadConfig(); - } - catch (Exception e) { - log.error("[Sentinel Starter] DataSource " + dataSourceName - + " loadConfig error: " + e.getMessage(), e); - return; - } - if (ruleConfig instanceof List || ruleConfig instanceof Set) { - Collection convertedRuleList = (Collection) ruleConfig; - if (CollectionUtils.isEmpty(convertedRuleList)) { - log.warn("[Sentinel Starter] DataSource {} rule list is empty.", - dataSourceName); - return; - } - if (convertedRuleList.stream() - .noneMatch(rule -> rule.getClass() == ruleClass)) { - log.error("[Sentinel Starter] DataSource {} none rules are {} type.", - dataSourceName, ruleClass.getSimpleName()); - throw new IllegalArgumentException("[Sentinel Starter] DataSource " - + dataSourceName + " none rules are " + ruleClass.getSimpleName() - + " type."); - } - else if (!convertedRuleList.stream() - .allMatch(rule -> rule.getClass() == ruleClass)) { - log.warn("[Sentinel Starter] DataSource {} all rules are not {} type.", - dataSourceName, ruleClass.getSimpleName()); - } - else { - log.info("[Sentinel Starter] DataSource {} load {} {}", dataSourceName, - convertedRuleList.size(), ruleClass.getSimpleName()); - } - } - else { - log.error("[Sentinel Starter] DataSource " + dataSourceName - + " rule class is not List<" + ruleClass.getSimpleName() - + ">. Class: " + ruleConfig.getClass()); - throw new IllegalArgumentException("[Sentinel Starter] DataSource " - + dataSourceName + " rule class is not List<" - + ruleClass.getSimpleName() + ">. Class: " + ruleConfig.getClass()); - } - } }