Skip to content

Commit 595b6ba

Browse files
authored
Merge branch '2.x' into 2.x_26_02_17
2 parents f92f0e4 + e006d10 commit 595b6ba

File tree

20 files changed

+3695
-17
lines changed

20 files changed

+3695
-17
lines changed

.mvn/wrapper/maven-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17-
distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
17+
distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.9.5/apache-maven-3.9.5-bin.zip
1818
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar

changes/en-us/2.x.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Add changes here for all PR submitted to the 2.x branch.
2424
- [[#7000](https://github.com/apache/incubator-seata/pull/7000)] support multi-version codec & fix not returning client registration failure msg.
2525
- [[#7865](https://github.com/apache/incubator-seata/pull/7865)] add Benchmark CLI tool
2626
- [[#7903](https://github.com/apache/incubator-seata/pull/7903)] Support HTTP/2 stream push for the Watch API in Server Raft mode
27-
27+
- [[#8002](https://github.com/apache/incubator-seata/pull/8002)] add Grafana dashboard JSON for NamingServer metrics
2828

2929
### bugfix:
3030

@@ -49,7 +49,10 @@ Add changes here for all PR submitted to the 2.x branch.
4949
### security:
5050

5151
### test:
52+
5253
- [[#7962](https://github.com/apache/incubator-seata/pull/7962)] add unit tests for NacosRegistryProvider and NacosRegistryServiceImpl
54+
- [[#8003](https://github.com/apache/incubator-seata/pull/8003)] Enhance NacosRegistryServiceImplTest with additional mocks for service name group and cluster
55+
- [[#7915](https://github.com/apache/incubator-seata/pull/7915)] add unit tests for saga-engine low coverage components
5356

5457
### refactor:
5558

changes/zh-cn/2.x.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
- [[#7000](https://github.com/apache/incubator-seata/pull/7000)] 支持多版本codec,修复不返回客户端注册失败消息的问题
2626
- [[#7865](https://github.com/apache/incubator-seata/pull/7865)] 新增 Benchmark 命令行工具
2727
- [[#7903](https://github.com/apache/incubator-seata/pull/7903)] 在Server Raft模式下支持Watch API的HTTP/2流推送
28+
- [[#8002](https://github.com/apache/incubator-seata/pull/8002)] 为namingserver指标增加Grafana dashboard JSON
2829

2930
### bugfix:
3031

@@ -54,7 +55,11 @@
5455

5556

5657
### test:
58+
5759
- [[#7962](https://github.com/apache/incubator-seata/pull/7962)] 为 NacosRegistryProvider 和 NacosRegistryServiceImpl 添加单元测试用例
60+
- [[#8003](https://github.com/apache/incubator-seata/pull/8003)] 为 NacosRegistryServiceImplTest 增加服务名称、分组和集群的额外模拟
61+
- [[#7915](https://github.com/apache/incubator-seata/pull/7915)] 为 saga-engine 添加单元测试用例
62+
5863

5964
### refactor:
6065

discovery/seata-discovery-nacos/src/main/java/org/apache/seata/discovery/registry/nacos/NacosRegistryServiceImpl.java

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,11 @@ public class NacosRegistryServiceImpl implements RegistryService<EventListener>
7272
private static final String PUBLIC_NAMING_ADDRESS_PREFIX = "public_";
7373
private static final String PUBLIC_NAMING_SERVICE_META_IP_KEY = "publicIp";
7474
private static final String PUBLIC_NAMING_SERVICE_META_PORT_KEY = "publicPort";
75-
private static final Configuration FILE_CONFIG = ConfigurationFactory.CURRENT_FILE_INSTANCE;
75+
// Use a method to retrieve file config dynamically to support test mocking on Java 17+
76+
private static Configuration getFileConfig() {
77+
return ConfigurationFactory.CURRENT_FILE_INSTANCE;
78+
}
79+
7680
private static volatile NamingService naming;
7781
private static final ConcurrentMap<String, List<EventListener>> LISTENER_SERVICE_MAP = new ConcurrentHashMap<>();
7882
private static final ConcurrentMap<String, List<InetSocketAddress>> CLUSTER_ADDRESS_MAP = new ConcurrentHashMap<>();
@@ -86,7 +90,7 @@ public class NacosRegistryServiceImpl implements RegistryService<EventListener>
8690
private String transactionServiceGroup;
8791

8892
private NacosRegistryServiceImpl() {
89-
String configForNacosSLB = FILE_CONFIG.getConfig(getNacosUrlPatternOfSLB());
93+
String configForNacosSLB = getFileConfig().getConfig(getNacosUrlPatternOfSLB());
9094
Pattern patternOfNacosRegistryForSLB = StringUtils.isBlank(configForNacosSLB)
9195
? DEFAULT_SLB_REGISTRY_PATTERN
9296
: Pattern.compile(configForNacosSLB);
@@ -278,15 +282,15 @@ private static Properties getNamingProperties() {
278282
if (System.getProperty(PRO_SERVER_ADDR_KEY) != null) {
279283
properties.setProperty(PRO_SERVER_ADDR_KEY, System.getProperty(PRO_SERVER_ADDR_KEY));
280284
} else {
281-
String address = FILE_CONFIG.getConfig(getNacosAddrFileKey());
285+
String address = getFileConfig().getConfig(getNacosAddrFileKey());
282286
if (address != null) {
283287
properties.setProperty(PRO_SERVER_ADDR_KEY, address);
284288
}
285289
}
286290
if (System.getProperty(PRO_NAMESPACE_KEY) != null) {
287291
properties.setProperty(PRO_NAMESPACE_KEY, System.getProperty(PRO_NAMESPACE_KEY));
288292
} else {
289-
String namespace = FILE_CONFIG.getConfig(getNacosNameSpaceFileKey());
293+
String namespace = getFileConfig().getConfig(getNacosNameSpaceFileKey());
290294
if (namespace == null) {
291295
namespace = DEFAULT_NAMESPACE;
292296
}
@@ -297,7 +301,7 @@ private static Properties getNamingProperties() {
297301
}
298302
String contextPath = StringUtils.isNotBlank(System.getProperty(CONTEXT_PATH))
299303
? System.getProperty(CONTEXT_PATH)
300-
: FILE_CONFIG.getConfig(getNacosContextPathKey());
304+
: getFileConfig().getConfig(getNacosContextPathKey());
301305
if (StringUtils.isNotBlank(contextPath)) {
302306
properties.setProperty(CONTEXT_PATH, contextPath);
303307
}
@@ -315,11 +319,11 @@ private static Properties getNamingProperties() {
315319
private static boolean initNacosAuthProperties(Properties sourceProperties) {
316320
String userName = StringUtils.isNotBlank(System.getProperty(USER_NAME))
317321
? System.getProperty(USER_NAME)
318-
: FILE_CONFIG.getConfig(getNacosUserName());
322+
: getFileConfig().getConfig(getNacosUserName());
319323
if (StringUtils.isNotBlank(userName)) {
320324
String password = StringUtils.isNotBlank(System.getProperty(PASSWORD))
321325
? System.getProperty(PASSWORD)
322-
: FILE_CONFIG.getConfig(getNacosPassword());
326+
: getFileConfig().getConfig(getNacosPassword());
323327
if (StringUtils.isNotBlank(password)) {
324328
sourceProperties.setProperty(USER_NAME, userName);
325329
sourceProperties.setProperty(PASSWORD, password);
@@ -329,14 +333,14 @@ private static boolean initNacosAuthProperties(Properties sourceProperties) {
329333
} else {
330334
String accessKey = StringUtils.isNotBlank(System.getProperty(ACCESS_KEY))
331335
? System.getProperty(ACCESS_KEY)
332-
: FILE_CONFIG.getConfig(getNacosAccessKey());
336+
: getFileConfig().getConfig(getNacosAccessKey());
333337
String ramRoleName = StringUtils.isNotBlank(System.getProperty(RAM_ROLE_NAME_KEY))
334338
? System.getProperty(RAM_ROLE_NAME_KEY)
335-
: FILE_CONFIG.getConfig(getNacosRamRoleNameKey());
339+
: getFileConfig().getConfig(getNacosRamRoleNameKey());
336340
if (StringUtils.isNotBlank(accessKey)) {
337341
String secretKey = StringUtils.isNotBlank(System.getProperty(SECRET_KEY))
338342
? System.getProperty(SECRET_KEY)
339-
: FILE_CONFIG.getConfig(getNacosSecretKey());
343+
: getFileConfig().getConfig(getNacosSecretKey());
340344
if (StringUtils.isNotBlank(secretKey)) {
341345
sourceProperties.put(ACCESS_KEY, accessKey);
342346
sourceProperties.put(SECRET_KEY, secretKey);
@@ -353,15 +357,15 @@ private static boolean initNacosAuthProperties(Properties sourceProperties) {
353357
}
354358

355359
private static String getClusterName() {
356-
return FILE_CONFIG.getConfig(getNacosClusterFileKey(), DEFAULT_CLUSTER);
360+
return getFileConfig().getConfig(getNacosClusterFileKey(), DEFAULT_CLUSTER);
357361
}
358362

359363
private static String getServiceName() {
360-
return FILE_CONFIG.getConfig(getNacosApplicationFileKey(), DEFAULT_APPLICATION);
364+
return getFileConfig().getConfig(getNacosApplicationFileKey(), DEFAULT_APPLICATION);
361365
}
362366

363367
private static String getServiceGroup() {
364-
return FILE_CONFIG.getConfig(getNacosApplicationGroupKey(), DEFAULT_GROUP);
368+
return getFileConfig().getConfig(getNacosApplicationGroupKey(), DEFAULT_GROUP);
365369
}
366370

367371
private static String getNacosAddrFileKey() {

discovery/seata-discovery-nacos/src/test/java/org/apache/seata/discovery/registry/nacos/NacosRegistryServiceImplTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,20 @@ public void beforeEach() throws Exception {
8888
when(mockedCurrentNacosConfiguration.getConfig(SLB_PATTERN_KEY)).thenReturn("");
8989
when(mockedCurrentNacosConfiguration.getConfig(SERVER_ADDR_KEY)).thenReturn("127.0.0.1");
9090

91+
// Mock for getServiceName() -> registry.nacos.application
92+
when(mockedCurrentNacosConfiguration.getConfig(APPLICATION_KEY)).thenReturn(NACOS_MOCKED_APPLICATION);
9193
when(mockedCurrentNacosConfiguration.getConfig(APPLICATION_KEY, "seata-server"))
9294
.thenReturn(NACOS_MOCKED_APPLICATION);
95+
96+
// Mock for getServiceGroup() -> registry.nacos.group
97+
when(mockedCurrentNacosConfiguration.getConfig(GROUP_KEY)).thenReturn(NACOS_MOCKED_GROUP);
9398
when(mockedCurrentNacosConfiguration.getConfig(GROUP_KEY, "DEFAULT_GROUP"))
9499
.thenReturn(NACOS_MOCKED_GROUP);
100+
101+
// Mock for getClusterName() -> registry.nacos.cluster
102+
when(mockedCurrentNacosConfiguration.getConfig(CLUSTER_KEY)).thenReturn(NACOS_MOCKED_CLUSTER);
95103
when(mockedCurrentNacosConfiguration.getConfig(CLUSTER_KEY, "default")).thenReturn(NACOS_MOCKED_CLUSTER);
104+
96105
when(mockedCurrentNacosConfiguration.getConfig(CONTEXT_PATH_KEY)).thenReturn("/foo");
97106

98107
nacosRegistryService = NacosRegistryServiceImpl.getInstance();

0 commit comments

Comments
 (0)