mirror of
https://gitee.com/mirrors/Spring-Cloud-Alibaba.git
synced 2021-06-26 13:25:11 +08:00
Polish alibaba/spring-cloud-alibaba#1758 : [CodeBase] Sync the source code from greenwich to finichley
This commit is contained in:
parent
201a4eaa01
commit
8cbd14b2bb
@ -67,14 +67,12 @@ import static com.alibaba.nacos.api.PropertyKeyConst.USERNAME;
|
||||
@ConfigurationProperties("spring.cloud.nacos.discovery")
|
||||
public class NacosDiscoveryProperties {
|
||||
|
||||
private static final Logger log = LoggerFactory
|
||||
.getLogger(NacosDiscoveryProperties.class);
|
||||
|
||||
/**
|
||||
* Prefix of {@link NacosDiscoveryProperties}.
|
||||
*/
|
||||
public static final String PREFIX = "spring.cloud.nacos.discovery";
|
||||
|
||||
private static final Logger log = LoggerFactory
|
||||
.getLogger(NacosDiscoveryProperties.class);
|
||||
private static final Pattern PATTERN = Pattern.compile("-(\\w)");
|
||||
|
||||
/**
|
||||
|
@ -42,21 +42,37 @@ public class NacosServiceInstance implements ServiceInstance {
|
||||
return serviceId;
|
||||
}
|
||||
|
||||
public void setServiceId(String serviceId) {
|
||||
this.serviceId = serviceId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHost() {
|
||||
return host;
|
||||
}
|
||||
|
||||
public void setHost(String host) {
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
public void setPort(int port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSecure() {
|
||||
return secure;
|
||||
}
|
||||
|
||||
public void setSecure(boolean secure) {
|
||||
this.secure = secure;
|
||||
}
|
||||
|
||||
@Override
|
||||
public URI getUri() {
|
||||
return DefaultServiceInstance.getUri(this);
|
||||
@ -67,22 +83,6 @@ public class NacosServiceInstance implements ServiceInstance {
|
||||
return metadata;
|
||||
}
|
||||
|
||||
public void setServiceId(String serviceId) {
|
||||
this.serviceId = serviceId;
|
||||
}
|
||||
|
||||
public void setHost(String host) {
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
public void setPort(int port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public void setSecure(boolean secure) {
|
||||
this.secure = secure;
|
||||
}
|
||||
|
||||
public void setMetadata(Map<String, String> metadata) {
|
||||
this.metadata = metadata;
|
||||
}
|
||||
|
@ -32,13 +32,11 @@ import org.springframework.cloud.client.discovery.DiscoveryClient;
|
||||
*/
|
||||
public class NacosDiscoveryClient implements DiscoveryClient {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(NacosDiscoveryClient.class);
|
||||
|
||||
/**
|
||||
* Nacos Discovery Client Description.
|
||||
*/
|
||||
public static final String DESCRIPTION = "Spring Cloud Nacos Discovery Client";
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(NacosDiscoveryClient.class);
|
||||
private NacosServiceDiscovery serviceDiscovery;
|
||||
|
||||
public NacosDiscoveryClient(NacosServiceDiscovery nacosServiceDiscovery) {
|
||||
|
@ -46,31 +46,6 @@ public class NacosServiceDiscovery {
|
||||
this.nacosServiceManager = nacosServiceManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all instances for the given service.
|
||||
* @param serviceId id of service
|
||||
* @return list of instances
|
||||
* @throws NacosException nacosException
|
||||
*/
|
||||
public List<ServiceInstance> getInstances(String serviceId) throws NacosException {
|
||||
String group = discoveryProperties.getGroup();
|
||||
List<Instance> instances = namingService().selectInstances(serviceId, group,
|
||||
true);
|
||||
return hostToServiceInstanceList(instances, serviceId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the names of all services.
|
||||
* @return list of service names
|
||||
* @throws NacosException nacosException
|
||||
*/
|
||||
public List<String> getServices() throws NacosException {
|
||||
String group = discoveryProperties.getGroup();
|
||||
ListView<String> services = namingService().getServicesOfServer(1,
|
||||
Integer.MAX_VALUE, group);
|
||||
return services.getData();
|
||||
}
|
||||
|
||||
public static List<ServiceInstance> hostToServiceInstanceList(
|
||||
List<Instance> instances, String serviceId) {
|
||||
List<ServiceInstance> result = new ArrayList<>(instances.size());
|
||||
@ -111,6 +86,31 @@ public class NacosServiceDiscovery {
|
||||
return nacosServiceInstance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all instances for the given service.
|
||||
* @param serviceId id of service
|
||||
* @return list of instances
|
||||
* @throws NacosException nacosException
|
||||
*/
|
||||
public List<ServiceInstance> getInstances(String serviceId) throws NacosException {
|
||||
String group = discoveryProperties.getGroup();
|
||||
List<Instance> instances = namingService().selectInstances(serviceId, group,
|
||||
true);
|
||||
return hostToServiceInstanceList(instances, serviceId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the names of all services.
|
||||
* @return list of service names
|
||||
* @throws NacosException nacosException
|
||||
*/
|
||||
public List<String> getServices() throws NacosException {
|
||||
String group = discoveryProperties.getGroup();
|
||||
ListView<String> services = namingService().getServicesOfServer(1,
|
||||
Integer.MAX_VALUE, group);
|
||||
return services.getData();
|
||||
}
|
||||
|
||||
private NamingService namingService() {
|
||||
return nacosServiceManager
|
||||
.getNamingService(discoveryProperties.getNacosProperties());
|
||||
|
@ -51,22 +51,14 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
||||
public class NacosWatch implements ApplicationEventPublisherAware, SmartLifecycle {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(NacosWatch.class);
|
||||
|
||||
private Map<String, EventListener> listenerMap = new ConcurrentHashMap<>(16);
|
||||
|
||||
private final AtomicBoolean running = new AtomicBoolean(false);
|
||||
|
||||
private final AtomicLong nacosWatchIndex = new AtomicLong(0);
|
||||
|
||||
private ApplicationEventPublisher publisher;
|
||||
|
||||
private ScheduledFuture<?> watchFuture;
|
||||
|
||||
private NacosServiceManager nacosServiceManager;
|
||||
|
||||
private final NacosDiscoveryProperties properties;
|
||||
|
||||
private final TaskScheduler taskScheduler;
|
||||
private Map<String, EventListener> listenerMap = new ConcurrentHashMap<>(16);
|
||||
private ApplicationEventPublisher publisher;
|
||||
private ScheduledFuture<?> watchFuture;
|
||||
private NacosServiceManager nacosServiceManager;
|
||||
|
||||
public NacosWatch(NacosServiceManager nacosServiceManager,
|
||||
NacosDiscoveryProperties properties,
|
||||
|
@ -72,6 +72,16 @@ public class NacosRegistration implements Registration, ServiceInstance {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
private static void customize(
|
||||
List<NacosRegistrationCustomizer> registrationCustomizers,
|
||||
NacosRegistration registration) {
|
||||
if (registrationCustomizers != null) {
|
||||
for (NacosRegistrationCustomizer customizer : registrationCustomizers) {
|
||||
customizer.customize(registration);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
|
||||
@ -112,16 +122,6 @@ public class NacosRegistration implements Registration, ServiceInstance {
|
||||
customize(registrationCustomizers, this);
|
||||
}
|
||||
|
||||
private static void customize(
|
||||
List<NacosRegistrationCustomizer> registrationCustomizers,
|
||||
NacosRegistration registration) {
|
||||
if (registrationCustomizers != null) {
|
||||
for (NacosRegistrationCustomizer customizer : registrationCustomizers) {
|
||||
customizer.customize(registration);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getServiceId() {
|
||||
return nacosDiscoveryProperties.getService();
|
||||
|
@ -61,18 +61,6 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen
|
||||
"spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848" }, webEnvironment = RANDOM_PORT)
|
||||
public class NacosAutoServiceRegistrationIpNetworkInterfaceTests {
|
||||
|
||||
@Autowired
|
||||
private NacosRegistration registration;
|
||||
|
||||
@Autowired
|
||||
private NacosAutoServiceRegistration nacosAutoServiceRegistration;
|
||||
|
||||
@Autowired
|
||||
private NacosDiscoveryProperties properties;
|
||||
|
||||
@Autowired
|
||||
private InetUtils inetUtils;
|
||||
|
||||
static {
|
||||
try {
|
||||
Method method = PowerMockito.method(NacosFactory.class, "createNamingService",
|
||||
@ -90,6 +78,15 @@ public class NacosAutoServiceRegistrationIpNetworkInterfaceTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private NacosRegistration registration;
|
||||
@Autowired
|
||||
private NacosAutoServiceRegistration nacosAutoServiceRegistration;
|
||||
@Autowired
|
||||
private NacosDiscoveryProperties properties;
|
||||
@Autowired
|
||||
private InetUtils inetUtils;
|
||||
|
||||
@Test
|
||||
public void contextLoads() throws Exception {
|
||||
assertThat(registration).isNotNull();
|
||||
|
@ -57,15 +57,6 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen
|
||||
"spring.cloud.nacos.discovery.ip=123.123.123.123" }, webEnvironment = RANDOM_PORT)
|
||||
public class NacosAutoServiceRegistrationIpTests {
|
||||
|
||||
@Autowired
|
||||
private NacosRegistration registration;
|
||||
|
||||
@Autowired
|
||||
private NacosAutoServiceRegistration nacosAutoServiceRegistration;
|
||||
|
||||
@Autowired
|
||||
private NacosDiscoveryProperties properties;
|
||||
|
||||
static {
|
||||
try {
|
||||
Method method = PowerMockito.method(NacosFactory.class, "createNamingService",
|
||||
@ -83,6 +74,13 @@ public class NacosAutoServiceRegistrationIpTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private NacosRegistration registration;
|
||||
@Autowired
|
||||
private NacosAutoServiceRegistration nacosAutoServiceRegistration;
|
||||
@Autowired
|
||||
private NacosDiscoveryProperties properties;
|
||||
|
||||
@Test
|
||||
public void contextLoads() throws Exception {
|
||||
assertThat(registration).isNotNull();
|
||||
|
@ -58,15 +58,6 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen
|
||||
"spring.cloud.nacos.discovery.port=8888" }, webEnvironment = RANDOM_PORT)
|
||||
public class NacosAutoServiceRegistrationManagementPortTests {
|
||||
|
||||
@Autowired
|
||||
private NacosRegistration registration;
|
||||
|
||||
@Autowired
|
||||
private NacosAutoServiceRegistration nacosAutoServiceRegistration;
|
||||
|
||||
@Autowired
|
||||
private NacosDiscoveryProperties properties;
|
||||
|
||||
static {
|
||||
try {
|
||||
Method method = PowerMockito.method(NacosFactory.class, "createNamingService",
|
||||
@ -84,6 +75,13 @@ public class NacosAutoServiceRegistrationManagementPortTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private NacosRegistration registration;
|
||||
@Autowired
|
||||
private NacosAutoServiceRegistration nacosAutoServiceRegistration;
|
||||
@Autowired
|
||||
private NacosDiscoveryProperties properties;
|
||||
|
||||
@Test
|
||||
public void contextLoads() throws Exception {
|
||||
assertThat(registration).isNotNull();
|
||||
|
@ -57,15 +57,6 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen
|
||||
"spring.cloud.nacos.discovery.port=8888" }, webEnvironment = RANDOM_PORT)
|
||||
public class NacosAutoServiceRegistrationPortTests {
|
||||
|
||||
@Autowired
|
||||
private NacosRegistration registration;
|
||||
|
||||
@Autowired
|
||||
private NacosAutoServiceRegistration nacosAutoServiceRegistration;
|
||||
|
||||
@Autowired
|
||||
private NacosDiscoveryProperties properties;
|
||||
|
||||
static {
|
||||
try {
|
||||
Method method = PowerMockito.method(NacosFactory.class, "createNamingService",
|
||||
@ -83,6 +74,13 @@ public class NacosAutoServiceRegistrationPortTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private NacosRegistration registration;
|
||||
@Autowired
|
||||
private NacosAutoServiceRegistration nacosAutoServiceRegistration;
|
||||
@Autowired
|
||||
private NacosDiscoveryProperties properties;
|
||||
|
||||
@Test
|
||||
public void contextLoads() throws Exception {
|
||||
assertThat(registration).isNotNull();
|
||||
|
@ -74,24 +74,6 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen
|
||||
"spring.cloud.nacos.discovery.ip-delete-timeout=9" }, webEnvironment = RANDOM_PORT)
|
||||
public class NacosAutoServiceRegistrationTests {
|
||||
|
||||
@Autowired
|
||||
private NacosRegistration registration;
|
||||
|
||||
@Autowired
|
||||
private NacosAutoServiceRegistration nacosAutoServiceRegistration;
|
||||
|
||||
@LocalServerPort
|
||||
private int port;
|
||||
|
||||
@Autowired
|
||||
private NacosDiscoveryProperties properties;
|
||||
|
||||
@Autowired
|
||||
private NacosServiceManager nacosServiceManager;
|
||||
|
||||
@Autowired
|
||||
private InetUtils inetUtils;
|
||||
|
||||
static {
|
||||
try {
|
||||
Method method = PowerMockito.method(NacosFactory.class, "createNamingService",
|
||||
@ -109,6 +91,19 @@ public class NacosAutoServiceRegistrationTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private NacosRegistration registration;
|
||||
@Autowired
|
||||
private NacosAutoServiceRegistration nacosAutoServiceRegistration;
|
||||
@LocalServerPort
|
||||
private int port;
|
||||
@Autowired
|
||||
private NacosDiscoveryProperties properties;
|
||||
@Autowired
|
||||
private NacosServiceManager nacosServiceManager;
|
||||
@Autowired
|
||||
private InetUtils inetUtils;
|
||||
|
||||
@Test
|
||||
public void contextLoads() throws Exception {
|
||||
assertThat(registration).isNotNull();
|
||||
|
@ -36,11 +36,9 @@ import org.springframework.util.StringUtils;
|
||||
*/
|
||||
public class SeataFeignClient implements Client {
|
||||
|
||||
private final Client delegate;
|
||||
|
||||
private final BeanFactory beanFactory;
|
||||
|
||||
private static final int MAP_SIZE = 16;
|
||||
private final Client delegate;
|
||||
private final BeanFactory beanFactory;
|
||||
|
||||
SeataFeignClient(BeanFactory beanFactory) {
|
||||
this.beanFactory = beanFactory;
|
||||
|
@ -35,17 +35,16 @@ import org.springframework.web.client.RestTemplate;
|
||||
@Configuration
|
||||
public class SeataRestTemplateAutoConfiguration {
|
||||
|
||||
@Autowired(required = false)
|
||||
private Collection<RestTemplate> restTemplates;
|
||||
@Autowired
|
||||
private SeataRestTemplateInterceptor seataRestTemplateInterceptor;
|
||||
|
||||
@Bean
|
||||
public SeataRestTemplateInterceptor seataRestTemplateInterceptor() {
|
||||
return new SeataRestTemplateInterceptor();
|
||||
}
|
||||
|
||||
@Autowired(required = false)
|
||||
private Collection<RestTemplate> restTemplates;
|
||||
|
||||
@Autowired
|
||||
private SeataRestTemplateInterceptor seataRestTemplateInterceptor;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
if (this.restTemplates != null) {
|
||||
|
@ -27,16 +27,14 @@ import com.alibaba.csp.sentinel.util.StringUtil;
|
||||
*/
|
||||
final class BlockClassRegistry {
|
||||
|
||||
private static final Map<String, Method> FALLBACK_MAP = new ConcurrentHashMap<>();
|
||||
private static final Map<String, Method> BLOCK_HANDLER_MAP = new ConcurrentHashMap<>();
|
||||
private static final Map<String, Method> URL_CLEANER_MAP = new ConcurrentHashMap<>();
|
||||
|
||||
private BlockClassRegistry() {
|
||||
|
||||
}
|
||||
|
||||
private static final Map<String, Method> FALLBACK_MAP = new ConcurrentHashMap<>();
|
||||
|
||||
private static final Map<String, Method> BLOCK_HANDLER_MAP = new ConcurrentHashMap<>();
|
||||
|
||||
private static final Map<String, Method> URL_CLEANER_MAP = new ConcurrentHashMap<>();
|
||||
|
||||
static Method lookupFallback(Class<?> clazz, String name) {
|
||||
return FALLBACK_MAP.get(getKey(clazz, name));
|
||||
}
|
||||
|
@ -56,13 +56,12 @@ public class SentinelBeanPostProcessor implements MergedBeanDefinitionPostProces
|
||||
.getLogger(SentinelBeanPostProcessor.class);
|
||||
|
||||
private final ApplicationContext applicationContext;
|
||||
private ConcurrentHashMap<String, SentinelRestTemplate> cache = new ConcurrentHashMap<>();
|
||||
|
||||
public SentinelBeanPostProcessor(ApplicationContext applicationContext) {
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
private ConcurrentHashMap<String, SentinelRestTemplate> cache = new ConcurrentHashMap<>();
|
||||
|
||||
@Override
|
||||
public void postProcessMergedBeanDefinition(RootBeanDefinition beanDefinition,
|
||||
Class<?> beanType, String beanName) {
|
||||
|
@ -52,20 +52,13 @@ public class SentinelDataSourceHandler implements SmartInitializingSingleton {
|
||||
|
||||
private static final Logger log = LoggerFactory
|
||||
.getLogger(SentinelDataSourceHandler.class);
|
||||
|
||||
private List<String> dataTypeList = Arrays.asList("json", "xml");
|
||||
|
||||
private final String DATA_TYPE_FIELD = "dataType";
|
||||
|
||||
private final String CUSTOM_DATA_TYPE = "custom";
|
||||
|
||||
private final String CONVERTER_CLASS_FIELD = "converterClass";
|
||||
|
||||
private final DefaultListableBeanFactory beanFactory;
|
||||
|
||||
private final SentinelProperties sentinelProperties;
|
||||
|
||||
private final Environment env;
|
||||
private List<String> dataTypeList = Arrays.asList("json", "xml");
|
||||
|
||||
public SentinelDataSourceHandler(DefaultListableBeanFactory beanFactory,
|
||||
SentinelProperties sentinelProperties, Environment env) {
|
||||
|
@ -76,7 +76,7 @@ public class SentinelHealthIndicator extends AbstractHealthIndicator {
|
||||
// detail
|
||||
if (!sentinelProperties.isEnabled()) {
|
||||
detailMap.put("enabled", false);
|
||||
builder.up().withDetails(detailMap);
|
||||
withDetails(builder.up(), detailMap);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -144,11 +144,16 @@ public class SentinelHealthIndicator extends AbstractHealthIndicator {
|
||||
|
||||
// If Dashboard and DataSource are both OK, the health status is UP
|
||||
if (dashboardUp && dataSourceUp) {
|
||||
builder.up().withDetails(detailMap);
|
||||
withDetails(builder.up(), detailMap);
|
||||
}
|
||||
else {
|
||||
builder.unknown().withDetails(detailMap);
|
||||
withDetails(builder.down(), detailMap);
|
||||
}
|
||||
}
|
||||
|
||||
private void withDetails(Health.Builder builder, Map<String, Object> detailMap) {
|
||||
for (String key : detailMap.keySet()) {
|
||||
builder.withDetail(key, detailMap.get(key));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -32,13 +32,12 @@ import feign.MethodMetadata;
|
||||
*/
|
||||
public class SentinelContractHolder implements Contract {
|
||||
|
||||
private final Contract delegate;
|
||||
|
||||
/**
|
||||
* map key is constructed by ClassFullName + configKey. configKey is constructed by
|
||||
* {@link feign.Feign#configKey}
|
||||
*/
|
||||
public final static Map<String, MethodMetadata> METADATA_MAP = new HashMap<>();
|
||||
private final Contract delegate;
|
||||
|
||||
public SentinelContractHolder(Contract delegate) {
|
||||
this.delegate = delegate;
|
||||
|
@ -65,13 +65,23 @@ public class SentinelInvocationHandler implements InvocationHandler {
|
||||
this.dispatch = checkNotNull(dispatch, "dispatch");
|
||||
}
|
||||
|
||||
static Map<Method, Method> toFallbackMethod(Map<Method, MethodHandler> dispatch) {
|
||||
Map<Method, Method> result = new LinkedHashMap<>();
|
||||
for (Method method : dispatch.keySet()) {
|
||||
method.setAccessible(true);
|
||||
result.put(method, method);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object invoke(final Object proxy, final Method method, final Object[] args)
|
||||
throws Throwable {
|
||||
if ("equals".equals(method.getName())) {
|
||||
try {
|
||||
Object otherHandler = args.length > 0 && args[0] != null
|
||||
? Proxy.getInvocationHandler(args[0]) : null;
|
||||
? Proxy.getInvocationHandler(args[0])
|
||||
: null;
|
||||
return equals(otherHandler);
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
@ -99,7 +109,7 @@ public class SentinelInvocationHandler implements InvocationHandler {
|
||||
}
|
||||
else {
|
||||
String resourceName = methodMetadata.template().method().toUpperCase()
|
||||
+ ":" + hardCodedTarget.url() + methodMetadata.template().path();
|
||||
+ ":" + hardCodedTarget.url() + methodMetadata.template().url();
|
||||
Entry entry = null;
|
||||
try {
|
||||
ContextUtil.enter(resourceName);
|
||||
@ -166,13 +176,4 @@ public class SentinelInvocationHandler implements InvocationHandler {
|
||||
return target.toString();
|
||||
}
|
||||
|
||||
static Map<Method, Method> toFallbackMethod(Map<Method, MethodHandler> dispatch) {
|
||||
Map<Method, Method> result = new LinkedHashMap<>();
|
||||
for (Method method : dispatch.keySet()) {
|
||||
method.setAccessible(true);
|
||||
result.put(method, method);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -61,14 +61,6 @@ public class ContextIdSentinelFeignTests {
|
||||
assertThat(echoService.equals(fooService)).isEqualTo(Boolean.FALSE);
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@EnableAutoConfiguration
|
||||
@ImportAutoConfiguration({ SentinelFeignAutoConfiguration.class })
|
||||
@EnableFeignClients
|
||||
public static class TestConfig {
|
||||
|
||||
}
|
||||
|
||||
@FeignClient(contextId = "echoService", name = "service-provider", fallback = EchoServiceFallback.class, configuration = FeignConfiguration.class)
|
||||
public interface EchoService {
|
||||
|
||||
@ -85,6 +77,14 @@ public class ContextIdSentinelFeignTests {
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@EnableAutoConfiguration
|
||||
@ImportAutoConfiguration({ SentinelFeignAutoConfiguration.class })
|
||||
@EnableFeignClients
|
||||
public static class TestConfig {
|
||||
|
||||
}
|
||||
|
||||
public static class FeignConfiguration {
|
||||
|
||||
@Bean
|
||||
|
@ -118,24 +118,6 @@ public class SentinelFeignTests {
|
||||
assertThat(echoService.equals(fooService)).isEqualTo(Boolean.FALSE);
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@EnableAutoConfiguration
|
||||
@ImportAutoConfiguration({ SentinelFeignAutoConfiguration.class })
|
||||
@EnableFeignClients
|
||||
public static class TestConfig {
|
||||
|
||||
@Bean
|
||||
public EchoServiceFallback echoServiceFallback() {
|
||||
return new EchoServiceFallback();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public CustomFallbackFactory customFallbackFactory() {
|
||||
return new CustomFallbackFactory();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@FeignClient(value = "test-service", fallback = EchoServiceFallback.class)
|
||||
public interface EchoService {
|
||||
|
||||
@ -172,6 +154,24 @@ public class SentinelFeignTests {
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@EnableAutoConfiguration
|
||||
@ImportAutoConfiguration({ SentinelFeignAutoConfiguration.class })
|
||||
@EnableFeignClients
|
||||
public static class TestConfig {
|
||||
|
||||
@Bean
|
||||
public EchoServiceFallback echoServiceFallback() {
|
||||
return new EchoServiceFallback();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public CustomFallbackFactory customFallbackFactory() {
|
||||
return new CustomFallbackFactory();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class EchoServiceFallback implements EchoService {
|
||||
|
||||
@Override
|
||||
|
@ -30,10 +30,8 @@ public class SidecarNacosDiscoveryClient implements SidecarDiscoveryClient {
|
||||
|
||||
private static final Logger log = LoggerFactory
|
||||
.getLogger(SidecarNacosDiscoveryClient.class);
|
||||
|
||||
private NacosServiceManager nacosServiceManager;
|
||||
|
||||
private final SidecarNacosDiscoveryProperties sidecarNacosDiscoveryProperties;
|
||||
private NacosServiceManager nacosServiceManager;
|
||||
|
||||
public SidecarNacosDiscoveryClient(NacosServiceManager nacosServiceManager,
|
||||
SidecarNacosDiscoveryProperties sidecarNacosDiscoveryProperties) {
|
||||
|
@ -111,7 +111,8 @@ public class DubboLoadBalancedRestTemplateAutoConfiguration implements
|
||||
@Override
|
||||
public void afterSingletonsInstantiated() {
|
||||
loadBalancerInterceptorBean = retryLoadBalancerInterceptor != null
|
||||
? retryLoadBalancerInterceptor : loadBalancerInterceptor;
|
||||
? retryLoadBalancerInterceptor
|
||||
: loadBalancerInterceptor;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -141,7 +141,8 @@ public class DubboNonWebApplicationEnvironmentPostProcessor
|
||||
DEFAULT_PROTOCOL);
|
||||
|
||||
return isRestProtocol(protocol)
|
||||
? environment.getProperty(PROTOCOL_PORT_PROPERTY_NAME) : null;
|
||||
? environment.getProperty(PROTOCOL_PORT_PROPERTY_NAME)
|
||||
: null;
|
||||
}
|
||||
|
||||
private String getRestPortFromProtocolsProperties(
|
||||
|
@ -127,8 +127,7 @@ public class DubboGenericServiceFactory {
|
||||
new PropertyEditorSupport() {
|
||||
|
||||
@Override
|
||||
public void setAsText(String text)
|
||||
throws IllegalArgumentException {
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
// Trim all whitespace
|
||||
String content = StringUtils.trimAllWhitespace(text);
|
||||
if (!StringUtils.hasText(content)) { // No content , ignore
|
||||
|
Loading…
x
Reference in New Issue
Block a user