This is an automated email from the ASF dual-hosted git repository.

jianbin pushed a commit to branch 2.x
in repository https://gitbox.apache.org/repos/asf/incubator-seata.git


The following commit(s) were added to refs/heads/2.x by this push:
     new a880678b64 optimize: modify the parameter name in refreshToken method 
(#7608)
a880678b64 is described below

commit a880678b646a1e35a9b163d79ec5fff0f1de38a1
Author: xiaoyu <[email protected]>
AuthorDate: Fri Aug 29 09:25:25 2025 +0800

    optimize: modify the parameter name in refreshToken method (#7608)
---
 changes/en-us/2.x.md                               |  1 +
 changes/zh-cn/2.x.md                               |  1 +
 .../NamingserverRegistryServiceImpl.java           |  4 +--
 .../NamingserverRegistryServiceImplTest.java       | 30 +++++++++++++++++++++-
 4 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/changes/en-us/2.x.md b/changes/en-us/2.x.md
index 1d3553a9bb..ce8fcd6dd8 100644
--- a/changes/en-us/2.x.md
+++ b/changes/en-us/2.x.md
@@ -45,6 +45,7 @@ Add changes here for all PR submitted to the 2.x branch.
 - [[#7577](https://github.com/seata/seata/pull/7577)]  remove the 4MB size 
limit when decompressing with zstd
 - [[#7578](https://github.com/seata/seata/pull/7578)]  zstd decompression is 
changed from jni to ZstdInputStream
 - [[#7591](https://github.com/seata/seata/pull/7591)]  Optimize default 
xssFilter config retrieval when no explicit configuration is provided
+- [[#7608](https://github.com/seata/seata/pull/7608)]  modify the parameter 
name in refreshToken method
 
 ### security:
 
diff --git a/changes/zh-cn/2.x.md b/changes/zh-cn/2.x.md
index 8996e47bd1..6085e4da45 100644
--- a/changes/zh-cn/2.x.md
+++ b/changes/zh-cn/2.x.md
@@ -43,6 +43,7 @@
 - [[#7576](https://github.com/seata/seata/pull/7576)] 针对配置变更增加空推保护
 - [[#7577](https://github.com/seata/seata/pull/7577)]  去除zstd解压时4MB的限制
 - [[#7591](https://github.com/seata/seata/pull/7591)]  
当没有显式配置xssFilter相关的配置时,优化获取默认配置的逻辑
+- [[#7608](https://github.com/seata/seata/pull/7608)]  修改refreshToken方法中的参数名称
 
 ### security:
 
diff --git 
a/discovery/seata-discovery-namingserver/src/main/java/org/apache/seata/discovery/registry/namingserver/NamingserverRegistryServiceImpl.java
 
b/discovery/seata-discovery-namingserver/src/main/java/org/apache/seata/discovery/registry/namingserver/NamingserverRegistryServiceImpl.java
index 9fe99573f9..8eb28c439f 100644
--- 
a/discovery/seata-discovery-namingserver/src/main/java/org/apache/seata/discovery/registry/namingserver/NamingserverRegistryServiceImpl.java
+++ 
b/discovery/seata-discovery-namingserver/src/main/java/org/apache/seata/discovery/registry/namingserver/NamingserverRegistryServiceImpl.java
@@ -564,7 +564,7 @@ public class NamingserverRegistryServiceImpl implements 
RegistryService<NamingLi
         return 
Arrays.stream(urlListStr.split(",")).collect(Collectors.toList());
     }
 
-    private static void refreshToken(String tcAddress) throws 
RetryableException {
+    private static void refreshToken(String namingServerAddress) throws 
RetryableException {
         // if username and password is not in config , return
         if (StringUtils.isBlank(USERNAME) || StringUtils.isBlank(PASSWORD)) {
             return;
@@ -577,7 +577,7 @@ public class NamingserverRegistryServiceImpl implements 
RegistryService<NamingLi
         header.put(HTTP.CONTENT_TYPE, 
ContentType.APPLICATION_JSON.getMimeType());
         String response = null;
         try (CloseableHttpResponse httpResponse =
-                HttpClientUtil.doPost("http://"; + tcAddress + 
"/api/v1/auth/login", param, header, 1000)) {
+                HttpClientUtil.doPost("http://"; + namingServerAddress + 
"/api/v1/auth/login", param, header, 1000)) {
             if (httpResponse != null) {
                 if (httpResponse.getStatusLine().getStatusCode() == 
HttpStatus.SC_OK) {
                     response = EntityUtils.toString(httpResponse.getEntity(), 
StandardCharsets.UTF_8);
diff --git 
a/discovery/seata-discovery-namingserver/src/test/java/org/apache/seata/discovery/registry/namingserver/NamingserverRegistryServiceImplTest.java
 
b/discovery/seata-discovery-namingserver/src/test/java/org/apache/seata/discovery/registry/namingserver/NamingserverRegistryServiceImplTest.java
index 46ac55ff35..4f72e1f5b1 100644
--- 
a/discovery/seata-discovery-namingserver/src/test/java/org/apache/seata/discovery/registry/namingserver/NamingserverRegistryServiceImplTest.java
+++ 
b/discovery/seata-discovery-namingserver/src/test/java/org/apache/seata/discovery/registry/namingserver/NamingserverRegistryServiceImplTest.java
@@ -16,6 +16,7 @@
  */
 package org.apache.seata.discovery.registry.namingserver;
 
+import org.apache.http.StatusLine;
 import org.apache.http.client.methods.CloseableHttpResponse;
 import org.apache.http.entity.ContentType;
 import org.apache.http.protocol.HTTP;
@@ -34,6 +35,7 @@ import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Disabled;
 import org.junit.jupiter.api.Test;
+import org.mockito.Mockito;
 import 
org.springframework.context.annotation.AnnotationConfigApplicationContext;
 import org.springframework.core.env.ConfigurableEnvironment;
 import org.springframework.core.env.MutablePropertySources;
@@ -54,6 +56,13 @@ import java.util.concurrent.atomic.AtomicBoolean;
 
 import static 
org.apache.seata.common.Constants.OBJECT_KEY_SPRING_CONFIGURABLE_ENVIRONMENT;
 import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.anyMap;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.mockStatic;
+import static org.mockito.Mockito.when;
 
 class NamingserverRegistryServiceImplTest {
 
@@ -64,9 +73,10 @@ class NamingserverRegistryServiceImplTest {
         System.setProperty("registry.seata.namespace", "dev");
         System.setProperty("registry.seata.cluster", "cluster1");
         System.setProperty("registry.seata.server-addr", "127.0.0.1:8080");
+        System.setProperty("registry.seata.username", "seata");
+        System.setProperty("registry.seata.password", "seata");
         AnnotationConfigApplicationContext context = new 
AnnotationConfigApplicationContext();
 
-        // 获取应用程序环境
         ConfigurableEnvironment environment = context.getEnvironment();
         MutablePropertySources propertySources = 
environment.getPropertySources();
         Properties customProperties = new Properties();
@@ -82,6 +92,8 @@ class NamingserverRegistryServiceImplTest {
         System.clearProperty("registry.seata.namespace");
         System.clearProperty("registry.seata.cluster");
         System.clearProperty("registry.seata.server-addr");
+        System.clearProperty("registry.seata.username");
+        System.clearProperty("registry.seata.password");
     }
 
     @Test
@@ -92,6 +104,22 @@ class NamingserverRegistryServiceImplTest {
         namingserverRegistryService.unregister(inetSocketAddress);
     }
 
+    @Test
+    public void testWatchCoversRefreshToken() throws Exception {
+
+        NamingserverRegistryServiceImpl spyService = 
Mockito.spy(NamingserverRegistryServiceImpl.getInstance());
+        doReturn("127.0.0.1:8081").when(spyService).getNamingAddr();
+
+        CloseableHttpResponse mockResponse = mock(CloseableHttpResponse.class);
+        StatusLine mockStatusLine = mock(StatusLine.class);
+        when(mockStatusLine.getStatusCode()).thenReturn(200);
+        when(mockResponse.getStatusLine()).thenReturn(mockStatusLine);
+        mockStatic(HttpClientUtil.class);
+        when(HttpClientUtil.doPost(anyString(), anyString(), anyMap(), 
anyInt()))
+                .thenReturn(mockResponse);
+        spyService.watch("testGroup");
+    }
+
     @Test
     @Disabled
     public void getNamingAddrsTest() {


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to