From 5585da415a768271442f548f574c619f61cfacc9 Mon Sep 17 00:00:00 2001 From: zkzlx Date: Wed, 11 Sep 2019 18:14:00 +0800 Subject: [PATCH 1/5] nacos 1.1.3 config data not exist --- .../cloud/nacos/NacosConfigManager.java | 15 ++++++- .../cloud/nacos/NacosConfigProperties.java | 24 +++++----- .../client/NacosPropertySourceLocator.java | 44 +++++++++++++------ .../nacos/parser/NacosDataParserHandler.java | 7 +-- 4 files changed, 59 insertions(+), 31 deletions(-) diff --git a/spring-cloud-alibaba-nacos-config/src/main/java/com/alibaba/cloud/nacos/NacosConfigManager.java b/spring-cloud-alibaba-nacos-config/src/main/java/com/alibaba/cloud/nacos/NacosConfigManager.java index 4b5e98f9..704c8a26 100644 --- a/spring-cloud-alibaba-nacos-config/src/main/java/com/alibaba/cloud/nacos/NacosConfigManager.java +++ b/spring-cloud-alibaba-nacos-config/src/main/java/com/alibaba/cloud/nacos/NacosConfigManager.java @@ -16,7 +16,12 @@ */ package com.alibaba.cloud.nacos; +import com.alibaba.nacos.api.NacosFactory; import com.alibaba.nacos.api.config.ConfigService; +import com.alibaba.nacos.api.exception.NacosException; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; @@ -25,7 +30,8 @@ import org.springframework.context.ApplicationContextAware; * @author liaochuntao */ public class NacosConfigManager implements ApplicationContextAware { - + private static final Logger log = LoggerFactory + .getLogger(NacosConfigManager.class); private ConfigService configService; public ConfigService getConfigService() { @@ -37,6 +43,11 @@ public class NacosConfigManager implements ApplicationContextAware { throws BeansException { NacosConfigProperties properties = applicationContext .getBean(NacosConfigProperties.class); - configService = properties.configServiceInstance(); + try { + configService = NacosFactory.createConfigService(properties.getConfigServiceProperties()); + properties.initConfigService(configService); + } catch (NacosException e) { + log.error("create config service error!properties={},e=,", properties, e); + } } } diff --git a/spring-cloud-alibaba-nacos-config/src/main/java/com/alibaba/cloud/nacos/NacosConfigProperties.java b/spring-cloud-alibaba-nacos-config/src/main/java/com/alibaba/cloud/nacos/NacosConfigProperties.java index d03c399f..dc108633 100644 --- a/spring-cloud-alibaba-nacos-config/src/main/java/com/alibaba/cloud/nacos/NacosConfigProperties.java +++ b/spring-cloud-alibaba-nacos-config/src/main/java/com/alibaba/cloud/nacos/NacosConfigProperties.java @@ -403,13 +403,19 @@ public class NacosConfigProperties { + refreshableDataids + '\'' + ", extConfig=" + extConfig + '}'; } + /** + * @see NacosConfigManager#getConfigService() + */ @Deprecated public ConfigService configServiceInstance() { + return configService; + } - if (null != configService) { - return configService; - } + public void initConfigService(ConfigService configService){ + this.configService = configService; + } + public Properties getConfigServiceProperties(){ Properties properties = new Properties(); properties.put(SERVER_ADDR, Objects.toString(this.serverAddr, "")); properties.put(ENCODE, Objects.toString(this.encode, "")); @@ -424,7 +430,6 @@ public class NacosConfigProperties { properties.put(CONFIG_RETRY_TIME, Objects.toString(this.configRetryTime, "")); properties.put(ENABLE_REMOTE_SYNC_CONFIG, Objects.toString(this.enableRemoteSyncConfig, "")); - String endpoint = Objects.toString(this.endpoint, ""); if (endpoint.contains(":")) { int index = endpoint.indexOf(":"); @@ -434,14 +439,7 @@ public class NacosConfigProperties { else { properties.put(ENDPOINT, endpoint); } - - try { - configService = NacosFactory.createConfigService(properties); - return configService; - } - catch (Exception e) { - log.error("create config service error!properties={},e=,", this, e); - return null; - } + return properties; } + } diff --git a/spring-cloud-alibaba-nacos-config/src/main/java/com/alibaba/cloud/nacos/client/NacosPropertySourceLocator.java b/spring-cloud-alibaba-nacos-config/src/main/java/com/alibaba/cloud/nacos/client/NacosPropertySourceLocator.java index 10a48cd8..35494afc 100644 --- a/spring-cloud-alibaba-nacos-config/src/main/java/com/alibaba/cloud/nacos/client/NacosPropertySourceLocator.java +++ b/spring-cloud-alibaba-nacos-config/src/main/java/com/alibaba/cloud/nacos/client/NacosPropertySourceLocator.java @@ -156,8 +156,13 @@ public class NacosPropertySourceLocator implements PropertySourceLocator { String fileExtension = properties.getFileExtension(); String nacosGroup = properties.getGroup(); + // load directly once by default + loadNacosDataIfPresent(compositePropertySource, dataIdPrefix, nacosGroup, + fileExtension, true); + // load with suffix, which have a higher priority than the default loadNacosDataIfPresent(compositePropertySource, dataIdPrefix + DOT + fileExtension, nacosGroup, fileExtension, true); + // Loaded with profile, which have a higher priority than the suffix for (String profile : environment.getActiveProfiles()) { String dataId = dataIdPrefix + SEP1 + profile + DOT + fileExtension; loadNacosDataIfPresent(compositePropertySource, dataId, nacosGroup, @@ -168,22 +173,35 @@ public class NacosPropertySourceLocator implements PropertySourceLocator { private void loadNacosDataIfPresent(final CompositePropertySource composite, final String dataId, final String group, String fileExtension, boolean isRefreshable) { - if (NacosContextRefresher.getRefreshCount() != 0) { - NacosPropertySource ps; - if (!isRefreshable) { - ps = NacosPropertySourceRepository.getNacosPropertySource(dataId); - } - else { - ps = nacosPropertySourceBuilder.build(dataId, group, fileExtension, true); - } + NacosPropertySource propertySource = this.loadNacosPropertySource(dataId, group, + fileExtension, isRefreshable); + this.addFirstPropertySource(composite, propertySource, false); + } - composite.addFirstPropertySource(ps); + private NacosPropertySource loadNacosPropertySource(final String dataId, + final String group, String fileExtension, boolean isRefreshable) { + if (NacosContextRefresher.getRefreshCount() != 0) { + if (!isRefreshable) { + return NacosPropertySourceRepository.getNacosPropertySource(dataId); + } } - else { - NacosPropertySource ps = nacosPropertySourceBuilder.build(dataId, group, - fileExtension, isRefreshable); - composite.addFirstPropertySource(ps); + return nacosPropertySourceBuilder.build(dataId, group, fileExtension, + isRefreshable); + } + + /** + * Add the nacos configuration to the first place and maybe ignore the empty + * configuration + */ + private void addFirstPropertySource(final CompositePropertySource composite, + NacosPropertySource nacosPropertySource, boolean ignoreEmpty) { + if (null == nacosPropertySource || null == composite) { + return; } + if (ignoreEmpty && nacosPropertySource.getSource().isEmpty()) { + return; + } + composite.addFirstPropertySource(nacosPropertySource); } private static void checkDataIdFileExtension(String[] dataIdArray) { diff --git a/spring-cloud-alibaba-nacos-config/src/main/java/com/alibaba/cloud/nacos/parser/NacosDataParserHandler.java b/spring-cloud-alibaba-nacos-config/src/main/java/com/alibaba/cloud/nacos/parser/NacosDataParserHandler.java index e3168c91..cc41bd36 100644 --- a/spring-cloud-alibaba-nacos-config/src/main/java/com/alibaba/cloud/nacos/parser/NacosDataParserHandler.java +++ b/spring-cloud-alibaba-nacos-config/src/main/java/com/alibaba/cloud/nacos/parser/NacosDataParserHandler.java @@ -24,8 +24,6 @@ import java.util.Properties; */ public class NacosDataParserHandler { - private static final NacosDataParserHandler HANDLER = new NacosDataParserHandler(); - private AbstractNacosDataParser parser; private NacosDataParserHandler() { @@ -68,7 +66,10 @@ public class NacosDataParserHandler { } public static NacosDataParserHandler getInstance() { - return HANDLER; + return ParserHandler.HANDLER; } + private static class ParserHandler { + private static final NacosDataParserHandler HANDLER = new NacosDataParserHandler(); + } } From 2d1bdbf3d2058d7611f8f5e03aa7dc8f3aa95d4f Mon Sep 17 00:00:00 2001 From: zkzlx Date: Wed, 11 Sep 2019 23:59:20 +0800 Subject: [PATCH 2/5] fix test error --- .../cloud/nacos/client/NacosPropertySourceLocator.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/spring-cloud-alibaba-nacos-config/src/main/java/com/alibaba/cloud/nacos/client/NacosPropertySourceLocator.java b/spring-cloud-alibaba-nacos-config/src/main/java/com/alibaba/cloud/nacos/client/NacosPropertySourceLocator.java index 35494afc..6a7dc6cc 100644 --- a/spring-cloud-alibaba-nacos-config/src/main/java/com/alibaba/cloud/nacos/client/NacosPropertySourceLocator.java +++ b/spring-cloud-alibaba-nacos-config/src/main/java/com/alibaba/cloud/nacos/client/NacosPropertySourceLocator.java @@ -173,6 +173,12 @@ public class NacosPropertySourceLocator implements PropertySourceLocator { private void loadNacosDataIfPresent(final CompositePropertySource composite, final String dataId, final String group, String fileExtension, boolean isRefreshable) { + if (null == dataId || dataId.trim().length() < 1) { + return; + } + if (null == group || group.trim().length() < 1) { + return; + } NacosPropertySource propertySource = this.loadNacosPropertySource(dataId, group, fileExtension, isRefreshable); this.addFirstPropertySource(composite, propertySource, false); From d610f0e4215def25fb00857b6a2735e87f66e072 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8E=E7=8E=89=E6=A1=94?= Date: Thu, 12 Sep 2019 12:09:14 +0800 Subject: [PATCH 3/5] Fix Duboo typo resolve https://github.com/alibaba/spring-cloud-alibaba/issues/933 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6f69e3dc..e4486835 100644 --- a/README.md +++ b/README.md @@ -108,7 +108,7 @@ Examples: [Alibaba Cloud OSS Example](https://github.com/alibaba/spring-cloud-alibaba/blob/master/spring-cloud-alibaba-examples/oss-example/readme.md) -[Duboo Spring Cloud Example](https://github.com/alibaba/spring-cloud-alibaba/blob/master/spring-cloud-alibaba-examples/spring-cloud-alibaba-dubbo-examples/README_CN.md) +[Dubbo Spring Cloud Example](https://github.com/alibaba/spring-cloud-alibaba/blob/master/spring-cloud-alibaba-examples/spring-cloud-alibaba-dubbo-examples/README_CN.md) ## Version control guidelines The version number of the project is in the form of x.x.x, where x is a number, starting from 0, and is not limited to the range 0~9. When the project is in the incubator phase, the version number is 0.x.x. From e774cbe74d6ccc155710516df07d4f089bf0150e Mon Sep 17 00:00:00 2001 From: zkzlx Date: Thu, 12 Sep 2019 15:22:22 +0800 Subject: [PATCH 4/5] supplement case and circleci test failed --- .../nacos/NacosConfigurationNoSuffixTest.java | 271 ++++++++++++++++++ ...SentinelCircuitBreakerIntegrationTest.java | 3 +- ...SentinelCircuitBreakerIntegrationTest.java | 3 +- 3 files changed, 275 insertions(+), 2 deletions(-) create mode 100644 spring-cloud-alibaba-nacos-config/src/test/java/com/alibaba/cloud/nacos/NacosConfigurationNoSuffixTest.java diff --git a/spring-cloud-alibaba-nacos-config/src/test/java/com/alibaba/cloud/nacos/NacosConfigurationNoSuffixTest.java b/spring-cloud-alibaba-nacos-config/src/test/java/com/alibaba/cloud/nacos/NacosConfigurationNoSuffixTest.java new file mode 100644 index 00000000..5edb7a9d --- /dev/null +++ b/spring-cloud-alibaba-nacos-config/src/test/java/com/alibaba/cloud/nacos/NacosConfigurationNoSuffixTest.java @@ -0,0 +1,271 @@ +/* + * Copyright (C) 2018 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.alibaba.cloud.nacos; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.NONE; + +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; +import java.util.Map; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.api.support.MethodProxy; +import org.powermock.core.classloader.annotations.PowerMockIgnore; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; +import org.powermock.modules.junit4.PowerMockRunnerDelegate; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.ImportAutoConfiguration; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.EnvironmentAware; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.env.CompositePropertySource; +import org.springframework.core.env.Environment; +import org.springframework.test.context.junit4.SpringRunner; + +import com.alibaba.cloud.nacos.client.NacosPropertySourceLocator; +import com.alibaba.cloud.nacos.endpoint.NacosConfigEndpoint; +import com.alibaba.cloud.nacos.endpoint.NacosConfigEndpointAutoConfiguration; +import com.alibaba.cloud.nacos.refresh.NacosRefreshHistory; +import com.alibaba.nacos.client.config.NacosConfigService; + +/** + * @author zkz + */ + +@RunWith(PowerMockRunner.class) +@PowerMockIgnore("javax.management.*") +@PowerMockRunnerDelegate(SpringRunner.class) +@PrepareForTest({ NacosConfigService.class }) +@SpringBootTest(classes = NacosConfigurationNoSuffixTest.TestConfig.class, properties = { + "spring.application.name=app-no-suffix", "spring.profiles.active=dev", + "spring.cloud.nacos.config.server-addr=127.0.0.1:8848", + "spring.cloud.nacos.config.namespace=test-namespace", + "spring.cloud.nacos.config.encode=utf-8", + "spring.cloud.nacos.config.timeout=1000", + "spring.cloud.nacos.config.group=test-group", + "spring.cloud.nacos.config.name=test-no-suffix-name", + "spring.cloud.nacos.config.cluster-name=test-cluster", + "spring.cloud.nacos.config.contextPath=test-contextpath", + "spring.cloud.nacos.config.ext-config[0].data-id=ext-json-test.json", + "spring.cloud.nacos.config.ext-config[1].data-id=ext-common02.properties", + "spring.cloud.nacos.config.ext-config[1].group=GLOBAL_GROUP", + "spring.cloud.nacos.config.shared-dataids=shared-data1.properties,shared-data2.xml", + "spring.cloud.nacos.config.accessKey=test-accessKey", + "spring.cloud.nacos.config.secretKey=test-secretKey" }, webEnvironment = NONE) +public class NacosConfigurationNoSuffixTest { + + static { + + try { + + Method method = PowerMockito.method(NacosConfigService.class, "getConfig", + String.class, String.class, long.class); + MethodProxy.proxy(method, new InvocationHandler() { + @Override + public Object invoke(Object proxy, Method method, Object[] args) + throws Throwable { + + if ("app-no-suffix".equals(args[0]) && "test-group".equals(args[1])) { + return "test-no-suffix=value-no-suffix-1"; + } + if ("app-no-suffix.properties".equals(args[0]) + && "test-group".equals(args[1])) { + return "test-no-suffix=value-no-suffix-2"; + } + + if ("test-no-suffix-name".equals(args[0]) + && "test-group".equals(args[1])) { + return "test-no-suffix-assign=assign-value-no-suffix-111"; + } + if ("test-no-suffix-name.properties".equals(args[0]) + && "test-group".equals(args[1])) { + return "test-no-suffix-assign=assign-value-no-suffix-222"; + } + if ("test-no-suffix-name-dev.properties".equals(args[0]) + && "test-group".equals(args[1])) { + return "test-no-suffix-assign=assign-dev-value-no-suffix-333"; + } + + if ("ext-json-test.json".equals(args[0]) + && "DEFAULT_GROUP".equals(args[1])) { + return "{\n" + " \"people\":{\n" + + " \"firstName\":\"Brett\",\n" + + " \"lastName\":\"McLaughlin\"\n" + " }\n" + + "}"; + } + + if ("ext-config-common02.properties".equals(args[0]) + && "GLOBAL_GROUP".equals(args[1])) { + return "global-ext-config=global-config-value-2"; + } + + if ("shared-data1.properties".equals(args[0]) + && "DEFAULT_GROUP".equals(args[1])) { + return "shared-name=shared-value-1"; + } + + if ("shared-data2.xml".equals(args[0]) + && "DEFAULT_GROUP".equals(args[1])) { + return " \n" + + " \n" + + " \n" + + " 开启服务 \n" + + " 初始化一下 \n" + + " \n" + " \n" + + " one\n" + + " \n" + + " three\n" + + " \n" + + " \n" + " \n" + + " 销毁一下 \n" + + " 关闭服务 \n" + + " \n" + " \n" + + " "; + } + + return ""; + } + }); + + } + catch (Exception ignore) { + ignore.printStackTrace(); + + } + } + + @Autowired + private NacosPropertySourceLocator locator; + + @Autowired + private NacosConfigProperties properties; + + @Autowired + private NacosRefreshHistory refreshHistory; + @Autowired + private Environment environment; + + @Test + public void contextLoads() throws Exception { + + assertNotNull("NacosPropertySourceLocator was not created", locator); + assertNotNull("NacosConfigProperties was not created", properties); + + checkoutNacosConfigServerAddr(); + checkoutNacosConfigNamespace(); + checkoutNacosConfigClusterName(); + checkoutNacosConfigAccessKey(); + checkoutNacosConfigSecrectKey(); + checkoutNacosConfigName(); + checkoutNacosConfigGroup(); + checkoutNacosConfigContextPath(); + checkoutNacosConfigFileExtension(); + checkoutNacosConfigTimeout(); + checkoutNacosConfigEncode(); + + checkoutEndpoint(); + checkEnvironmentProperties(); + } + + private void checkEnvironmentProperties() { + assertNull( + "The configuration of `spring.cloud.nacos.config.name` must be used first", + environment.getProperty("test-no-suffix")); + assertEquals( + "Priority of configuration is wrong , should be in this order : `profile->hasSuffix->noSuffix`", + "assign-dev-value-no-suffix-333", + environment.getProperty("test-no-suffix-assign")); + + } + + private void checkoutNacosConfigServerAddr() { + assertEquals("NacosConfigProperties server address is wrong", "127.0.0.1:8848", + properties.getServerAddr()); + } + + private void checkoutNacosConfigNamespace() { + assertEquals("NacosConfigProperties namespace is wrong", "test-namespace", + properties.getNamespace()); + } + + private void checkoutNacosConfigClusterName() { + assertEquals("NacosConfigProperties' cluster is wrong", "test-cluster", + properties.getClusterName()); + } + + private void checkoutNacosConfigAccessKey() { + assertEquals("NacosConfigProperties' is access key is wrong", "test-accessKey", + properties.getAccessKey()); + } + + private void checkoutNacosConfigSecrectKey() { + assertEquals("NacosConfigProperties' is secret key is wrong", "test-secretKey", + properties.getSecretKey()); + } + + private void checkoutNacosConfigContextPath() { + assertEquals("NacosConfigProperties' context path is wrong", "test-contextpath", + properties.getContextPath()); + } + + private void checkoutNacosConfigName() { + assertEquals("NacosConfigProperties' name is wrong", "test-no-suffix-name", + properties.getName()); + } + + private void checkoutNacosConfigGroup() { + assertEquals("NacosConfigProperties' group is wrong", "test-group", + properties.getGroup()); + } + + private void checkoutNacosConfigFileExtension() { + assertEquals("NacosConfigProperties' file extension is wrong", "properties", + properties.getFileExtension()); + } + + private void checkoutNacosConfigTimeout() { + assertEquals("NacosConfigProperties' timeout is wrong", 1000, + properties.getTimeout()); + } + + private void checkoutNacosConfigEncode() { + assertEquals("NacosConfigProperties' encode is wrong", "utf-8", + properties.getEncode()); + } + + private void checkoutEndpoint() throws Exception { + NacosConfigEndpoint nacosConfigEndpoint = new NacosConfigEndpoint(properties, + refreshHistory); + Map map = nacosConfigEndpoint.invoke(); + assertEquals(map.get("NacosConfigProperties"), properties); + assertEquals(map.get("RefreshHistory"), refreshHistory.getRecords()); + } + + @Configuration + @EnableAutoConfiguration + @ImportAutoConfiguration({ NacosConfigEndpointAutoConfiguration.class, + NacosConfigAutoConfiguration.class, NacosConfigBootstrapConfiguration.class }) + public static class TestConfig { + } +} diff --git a/spring-cloud-circuitbreaker-sentinel/src/test/java/com/alibaba/cloud/circuitbreaker/sentinel/ReactiveSentinelCircuitBreakerIntegrationTest.java b/spring-cloud-circuitbreaker-sentinel/src/test/java/com/alibaba/cloud/circuitbreaker/sentinel/ReactiveSentinelCircuitBreakerIntegrationTest.java index b0a2b03a..9f90a71c 100644 --- a/spring-cloud-circuitbreaker-sentinel/src/test/java/com/alibaba/cloud/circuitbreaker/sentinel/ReactiveSentinelCircuitBreakerIntegrationTest.java +++ b/spring-cloud-circuitbreaker-sentinel/src/test/java/com/alibaba/cloud/circuitbreaker/sentinel/ReactiveSentinelCircuitBreakerIntegrationTest.java @@ -50,7 +50,8 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen * @author Ryan Baxter */ @RunWith(SpringRunner.class) -@SpringBootTest(webEnvironment = RANDOM_PORT, classes = ReactiveSentinelCircuitBreakerIntegrationTest.Application.class) +@SpringBootTest(webEnvironment = RANDOM_PORT, classes = ReactiveSentinelCircuitBreakerIntegrationTest.Application.class, properties = { + "spring.cloud.discovery.client.health-indicator.enabled=false" }) @DirtiesContext public class ReactiveSentinelCircuitBreakerIntegrationTest { diff --git a/spring-cloud-circuitbreaker-sentinel/src/test/java/com/alibaba/cloud/circuitbreaker/sentinel/SentinelCircuitBreakerIntegrationTest.java b/spring-cloud-circuitbreaker-sentinel/src/test/java/com/alibaba/cloud/circuitbreaker/sentinel/SentinelCircuitBreakerIntegrationTest.java index 7c1e57eb..34c51ea5 100644 --- a/spring-cloud-circuitbreaker-sentinel/src/test/java/com/alibaba/cloud/circuitbreaker/sentinel/SentinelCircuitBreakerIntegrationTest.java +++ b/spring-cloud-circuitbreaker-sentinel/src/test/java/com/alibaba/cloud/circuitbreaker/sentinel/SentinelCircuitBreakerIntegrationTest.java @@ -48,7 +48,8 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen * @author Eric Zhao */ @RunWith(SpringRunner.class) -@SpringBootTest(webEnvironment = RANDOM_PORT, classes = SentinelCircuitBreakerIntegrationTest.Application.class) +@SpringBootTest(webEnvironment = RANDOM_PORT, classes = SentinelCircuitBreakerIntegrationTest.Application.class, properties = { + "spring.cloud.discovery.client.health-indicator.enabled=false" }) @DirtiesContext public class SentinelCircuitBreakerIntegrationTest { From 9ab9141895f9ae11ac7bd820ad26c13a051ce082 Mon Sep 17 00:00:00 2001 From: zkzlx Date: Thu, 12 Sep 2019 15:41:40 +0800 Subject: [PATCH 5/5] format code --- .../java/com/alibaba/cloud/nacos/NacosConfigManager.java | 9 +++++---- .../com/alibaba/cloud/nacos/NacosConfigProperties.java | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/spring-cloud-alibaba-nacos-config/src/main/java/com/alibaba/cloud/nacos/NacosConfigManager.java b/spring-cloud-alibaba-nacos-config/src/main/java/com/alibaba/cloud/nacos/NacosConfigManager.java index 704c8a26..4cf39980 100644 --- a/spring-cloud-alibaba-nacos-config/src/main/java/com/alibaba/cloud/nacos/NacosConfigManager.java +++ b/spring-cloud-alibaba-nacos-config/src/main/java/com/alibaba/cloud/nacos/NacosConfigManager.java @@ -30,8 +30,7 @@ import org.springframework.context.ApplicationContextAware; * @author liaochuntao */ public class NacosConfigManager implements ApplicationContextAware { - private static final Logger log = LoggerFactory - .getLogger(NacosConfigManager.class); + private static final Logger log = LoggerFactory.getLogger(NacosConfigManager.class); private ConfigService configService; public ConfigService getConfigService() { @@ -44,9 +43,11 @@ public class NacosConfigManager implements ApplicationContextAware { NacosConfigProperties properties = applicationContext .getBean(NacosConfigProperties.class); try { - configService = NacosFactory.createConfigService(properties.getConfigServiceProperties()); + configService = NacosFactory + .createConfigService(properties.getConfigServiceProperties()); properties.initConfigService(configService); - } catch (NacosException e) { + } + catch (NacosException e) { log.error("create config service error!properties={},e=,", properties, e); } } diff --git a/spring-cloud-alibaba-nacos-config/src/main/java/com/alibaba/cloud/nacos/NacosConfigProperties.java b/spring-cloud-alibaba-nacos-config/src/main/java/com/alibaba/cloud/nacos/NacosConfigProperties.java index dc108633..1537002c 100644 --- a/spring-cloud-alibaba-nacos-config/src/main/java/com/alibaba/cloud/nacos/NacosConfigProperties.java +++ b/spring-cloud-alibaba-nacos-config/src/main/java/com/alibaba/cloud/nacos/NacosConfigProperties.java @@ -411,11 +411,11 @@ public class NacosConfigProperties { return configService; } - public void initConfigService(ConfigService configService){ + public void initConfigService(ConfigService configService) { this.configService = configService; } - public Properties getConfigServiceProperties(){ + public Properties getConfigServiceProperties() { Properties properties = new Properties(); properties.put(SERVER_ADDR, Objects.toString(this.serverAddr, "")); properties.put(ENCODE, Objects.toString(this.encode, ""));