Reconnect to auth url in case of ClientProtocolException
We had a case where the authorization VIP was reset after the monasca-api started. The auth connection pool did not try to reconnect since we did not meet the configured idle time, and we had to restart the monasca-api. This fix will allow the monasca-api to reconnect the auth pool connections when we get an exception. Change-Id: I7e45970360720193b2d0ba27964bc22f66db79d3
This commit is contained in:
parent
6a67fecc80
commit
5ea4d3cdf9
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
* (C) Copyright 2014,2016 Hewlett Packard Enterprise Development LP
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License. You may obtain a copy of the License at
|
||||
@ -42,12 +42,19 @@ public class TokenCache {
|
||||
|
||||
String value = null;
|
||||
AuthClient client = null;
|
||||
boolean discarded = false;
|
||||
|
||||
try {
|
||||
client = factory.getClient();
|
||||
value = client.validateTokenForServiceEndpointV3(key);
|
||||
} catch (ClientProtocolException e) {
|
||||
factory.discard(client);
|
||||
logger.warn("Validate token failed with ClientProtocolException. Discarding AuthClient connection from pool to create a new connection.");
|
||||
logger.warn("ClientProtocolException " + e.getMessage() + " " + e);
|
||||
discarded = true;
|
||||
throw e;
|
||||
} finally {
|
||||
if (client != null)
|
||||
if (client != null && !discarded)
|
||||
factory.recycle(client);
|
||||
}
|
||||
return value;
|
||||
|
Loading…
Reference in New Issue
Block a user