Merge "Reconnect to auth url in case of ClientProtocolException"

This commit is contained in:
Jenkins 2016-08-20 03:41:49 +00:00 committed by Gerrit Code Review
commit 1ad8b00ae2
1 changed files with 12 additions and 5 deletions

View File

@ -1,11 +1,11 @@
/*
* 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
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
@ -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;