Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: Enhance 401 Error Handling by Refreshing Token in acquireClusterMetaData Method #6923

Open
wants to merge 6 commits into
base: 2.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changes/en-us/2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)


Expand Down
4 changes: 4 additions & 0 deletions changes/zh-cn/2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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和建议,非常感谢大家。

Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading