Skip to content

Commit

Permalink
Retry connection if CSRF crumb retrieval results in HTTP 5xx error (#571
Browse files Browse the repository at this point in the history
)
  • Loading branch information
jimklimov authored Jan 5, 2024
1 parent ab1a7a0 commit ad27563
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion client/src/main/java/hudson/plugins/swarm/SwarmClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ static void addAuthorizationHeader(HttpRequest.Builder builder, Options clientOp
}

private static synchronized Crumb getCsrfCrumb(HttpClient client, Options options, URL url)
throws IOException, InterruptedException {
throws IOException, InterruptedException, RetryException {
logger.finer("getCsrfCrumb() invoked");

String[] crumbResponse;
Expand All @@ -265,6 +265,9 @@ private static synchronized Crumb getCsrfCrumb(HttpClient client, Options option
String.format(
"Could not obtain CSRF crumb. Response code: %s%n%s",
response.statusCode(), response.body()));
if (response.statusCode() >= 500 && response.statusCode() < 600)
throw new RetryException("Failed to obtain CSRF crumb due to an Internal Server "
+ "Error or similar condition. Response code: " + response.statusCode());
return null;
}

Expand Down

0 comments on commit ad27563

Please sign in to comment.