Skip to content

Commit 16b536e

Browse files
adamkoryntabuilduser
andauthored
CWMSVUE-751 do not try to authenticate more than once (#300)
* CWMSVUE-751 do not try to authenticate more than once we want to make sure that the actual unauthorized response is returned rather than getting stuck in an unauthenticated loop * Autogenerated JaCoCo coverage badge --------- Co-authored-by: builduser <builduser@rmanet.com>
1 parent a7d4541 commit 16b536e

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

.github/coveragereport/badge_branchcoverage.svg

Lines changed: 1 addition & 1 deletion
Loading

cwms-http-client/src/main/java/mil/army/usace/hec/cwms/http/client/OAuth2TokenAuthenticator.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ final class OAuth2TokenAuthenticator implements Authenticator {
4949

5050
@Override
5151
public synchronized Request authenticate(Route route, Response response) throws IOException {
52+
if(response.priorResponse() != null && response.priorResponse().priorResponse() != null) {
53+
//We've already tried to authenticate, we must not have proper credentials;
54+
return null;
55+
}
5256
OAuth2Token token = tokenProvider.getToken();
5357
if (token == null) {
5458
throw new IOException("Attempt to refresh token failed: No token retrieved from " + OAuth2TokenProvider.class.getName());

0 commit comments

Comments
 (0)