diff --git a/changes/en-us/2.x.md b/changes/en-us/2.x.md index f951c973c78..a44ec1d5aa0 100644 --- a/changes/en-us/2.x.md +++ b/changes/en-us/2.x.md @@ -12,6 +12,7 @@ Add changes here for all PR submitted to the 2.x branch. - [[#6899](https://github.com/apache/incubator-seata/pull/6899)] fix file.conf read failed after package - [[#6890](https://github.com/apache/incubator-seata/pull/6890)] fix designerJson to standardJson: subStateMachine compensateState cannot be recognized - [[#6907](https://github.com/apache/incubator-seata/pull/6907)] fix the issue of Codecov not generating reports +- [[#6923](https://github.com/apache/incubator-seata/pull/6923)] Enhance 401 Error Handling by Refreshing Token - [[#6925](https://github.com/apache/incubator-seata/pull/6925)] fix the issue in Raft model a follower's crash may lead to the continued use of expired tokens ### optimize: @@ -53,6 +54,7 @@ Thanks to these contributors for their code commits. Please report an unintended - [dsomehan](https://github.com/dsomehan) - [psxjoy](https://github.com/psxjoy) - [xingfudeshi](https://github.com/xingfudeshi) +- [o-jimin](https://github.com/o-jimin) - [lixingjia77](https://github.com/lixingjia77) diff --git a/changes/zh-cn/2.x.md b/changes/zh-cn/2.x.md index 8f83c2af5f4..05d217ae562 100644 --- a/changes/zh-cn/2.x.md +++ b/changes/zh-cn/2.x.md @@ -12,8 +12,10 @@ - [[#6899](https://github.com/apache/incubator-seata/pull/6899)] 修复file.conf打包后的读取 - [[#6890](https://github.com/apache/incubator-seata/pull/6890)] 修复saga设计json转标准json过程中: 子状态机补偿节点无法被识别 - [[#6907](https://github.com/apache/incubator-seata/pull/6907)] 修复Codecov未生成报告的问题 +- [[#6923](https://github.com/apache/incubator-seata/pull/6923)] 增强 401 错误处理,通过刷新令牌 - [[#6925](https://github.com/apache/incubator-seata/pull/6925)] 修复Raft模式下,Follower崩溃可能导致Client继续使用过期令牌的问题 + ### optimize: - [[#6826](https://github.com/apache/incubator-seata/pull/6826)] 移除只读XA事务的分支注册操作 - [[#6874](https://github.com/apache/incubator-seata/pull/6874)] modify the version to 2.3.0-SNAPSHOT @@ -55,7 +57,9 @@ - [dsomehan](https://github.com/dsomehan) - [psxjoy](https://github.com/psxjoy) - [xingfudeshi](https://github.com/xingfudeshi) +- [o-jimin](https://github.com/o-jimin) - [lixingjia77](https://github.com/lixingjia77) + 同时,我们收到了社区反馈的很多有价值的issue和建议,非常感谢大家。 diff --git a/discovery/seata-discovery-raft/src/main/java/org/apache/seata/discovery/registry/raft/RaftRegistryServiceImpl.java b/discovery/seata-discovery-raft/src/main/java/org/apache/seata/discovery/registry/raft/RaftRegistryServiceImpl.java index b5a28967ec4..8ba0d2256ed 100644 --- a/discovery/seata-discovery-raft/src/main/java/org/apache/seata/discovery/registry/raft/RaftRegistryServiceImpl.java +++ b/discovery/seata-discovery-raft/src/main/java/org/apache/seata/discovery/registry/raft/RaftRegistryServiceImpl.java @@ -377,14 +377,18 @@ private static void acquireClusterMetaData(String clusterName, String group) thr try (CloseableHttpResponse httpResponse = HttpClientUtil.doGet("http://" + tcAddress + "/metadata/v1/cluster", param, header, 1000)) { if (httpResponse != null) { - if (httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { + int statusCode = httpResponse.getStatusLine().getStatusCode(); + if (statusCode == HttpStatus.SC_OK) { response = EntityUtils.toString(httpResponse.getEntity(), StandardCharsets.UTF_8); - } else if (httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_UNAUTHORIZED) { + } else if (statusCode == HttpStatus.SC_UNAUTHORIZED) { if (StringUtils.isNotBlank(USERNAME) && StringUtils.isNotBlank(PASSWORD)) { - throw new RetryableException("Authentication failed!"); + refreshToken(tcAddress); + throw new RetryableException("Token refreshed, retrying request."); } else { throw new AuthenticationFailedException("Authentication failed! you should configure the correct username and password."); } + } else { + throw new AuthenticationFailedException("Authentication failed! you should configure the correct username and password."); } } MetadataResponse metadataResponse;