Skip to content

Commit 69523ca

Browse files
committed
fix try-finally location based on tests failing
1 parent b5abd72 commit 69523ca

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

connectors/httpclient/src/main/java/org/openstack4j/connectors/httpclient/HttpExecutorServiceImpl.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
public class HttpExecutorServiceImpl implements HttpExecutorService {
2020

2121
private static final String NAME = "Apache HttpClient Connector";
22-
22+
2323
/**
2424
* {@inheritDoc}
2525
*/
@@ -58,17 +58,19 @@ private <R> HttpResponse invoke(HttpRequest<R> request) throws Exception {
5858

5959
private <R> HttpResponse invokeRequest(HttpCommand<R> command) throws Exception {
6060
CloseableHttpResponse response = command.execute();
61-
try
61+
62+
if (command.getRetries() == 0 && response.getStatusLine().getStatusCode() == 401 && !command.getRequest().getHeaders().containsKey(ClientConstants.HEADER_OS4J_AUTH))
6263
{
63-
if (command.getRetries() == 0 && response.getStatusLine().getStatusCode() == 401 && !command.getRequest().getHeaders().containsKey(ClientConstants.HEADER_OS4J_AUTH))
64+
try
6465
{
6566
OSAuthenticator.reAuthenticate();
6667
command.getRequest().getHeaders().put(ClientConstants.HEADER_X_AUTH_TOKEN, OSClientSession.getCurrent().getTokenId());
6768
return invokeRequest(command.incrementRetriesAndReturn());
69+
} finally {
70+
response.close();
6871
}
69-
} finally {
70-
response.close();
7172
}
73+
7274
return HttpResponseImpl.wrap(response);
7375
}
7476

0 commit comments

Comments
 (0)