mirror of https://github.com/apache/jclouds.git
A 401 error should result in re-authenticating for a new token
This commit is contained in:
parent
60e9062894
commit
833f046a5c
|
@ -64,8 +64,8 @@ public class RetryOnRenew implements HttpRetryHandler {
|
||||||
retry = false;
|
retry = false;
|
||||||
} else {
|
} else {
|
||||||
byte[] content = closeClientButKeepContentStream(response);
|
byte[] content = closeClientButKeepContentStream(response);
|
||||||
//TODO: what is the error when the session token expires??
|
// Error when the session token expires: HTTP/1.1 401 Unauthorized, no body (or provider-specific response body)
|
||||||
if (content != null && new String(content).contains("lease renew")) {
|
if (content != null) {
|
||||||
logger.debug("invalidating authentication token");
|
logger.debug("invalidating authentication token");
|
||||||
authenticationResponseCache.invalidateAll();
|
authenticationResponseCache.invalidateAll();
|
||||||
retry = true;
|
retry = true;
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class RetryOnRenewTest {
|
||||||
cache.invalidateAll();
|
cache.invalidateAll();
|
||||||
expectLastCall();
|
expectLastCall();
|
||||||
|
|
||||||
expect(response.getPayload()).andReturn(Payloads.newStringPayload("token expired, please renew")).anyTimes();
|
expect(response.getPayload()).andReturn(Payloads.newStringPayload("")).anyTimes();
|
||||||
expect(response.getStatusCode()).andReturn(401).atLeastOnce();
|
expect(response.getStatusCode()).andReturn(401).atLeastOnce();
|
||||||
|
|
||||||
replay(command);
|
replay(command);
|
||||||
|
|
Loading…
Reference in New Issue