Skip to content

Commit

Permalink
fix: GSE V2 查询任务结果 API 重试机制不生效 TencentBlueKing#2729
Browse files Browse the repository at this point in the history
  • Loading branch information
wangyu096 committed Jan 10, 2024
1 parent 40e220f commit d33e43f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,12 @@ private void setEntity(HttpEntityEnclosingRequest request, HttpRequest httpReque

private HttpContext buildHttpContext(HttpRequest request) {
HttpCoreContext httpContext = HttpCoreContext.create();
httpContext.setAttribute(HttpContextAttributeNames.RETRY_MODE, request.getRetryMode().getValue());
if (request.getRetryMode() != null) {
httpContext.setAttribute(HttpContextAttributeNames.RETRY_MODE, request.getRetryMode().getValue());
}
if (request.getIdempotent() != null) {
httpContext.setAttribute(HttpContextAttributeNames.IS_IDEMPOTENT, request.getIdempotent());
}
return httpContext;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ private boolean checkIsRetrySafe(HttpContext context, IOException exception) {
private boolean isRequestIdempotent(HttpContext context) {
// 判断方法使用幂等
Object isIdempotentAttrVal = context.getAttribute(HttpContextAttributeNames.IS_IDEMPOTENT);
if (log.isDebugEnabled()) {
log.debug("HttpContext::IS_IDEMPOTENT: {}", isIdempotentAttrVal);
}
boolean isIdempotent = isIdempotentAttrVal != null && (boolean) isIdempotentAttrVal;
if (isIdempotent) {
// 如果上下文主动设置了该请求的幂等参数,那么优先使用
Expand All @@ -146,6 +149,9 @@ private boolean isRequestIdempotent(HttpContext context) {
final HttpRequest request = clientContext.getRequest();
final String method = request.getRequestLine().getMethod().toUpperCase(Locale.ROOT);
final Boolean b = this.retryMethods.get(method);
if (log.isDebugEnabled()) {
log.debug("Method: {}, isRequestIdempotent: {}",method, isIdempotentAttrVal);
}
return b != null && b;
}

Expand Down

0 comments on commit d33e43f

Please sign in to comment.