Skip to content

Commit 3be18b0

Browse files
committed
Issue #400 - insure closure on re-authentication
1 parent e5742ff commit 3be18b0

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

connectors/http-connector/src/main/java/org/openstack4j/connectors/http/HttpExecutorServiceImpl.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,15 @@ private <R> HttpResponse invokeRequest(HttpCommand<R> command) throws Exception
5959
HttpResponse response = command.execute();
6060

6161
if (command.getRetries() == 0 && response.getStatus() == 401 && !command.getRequest().getHeaders().containsKey(ClientConstants.HEADER_OS4J_AUTH)) {
62-
OSAuthenticator.reAuthenticate();
63-
command.getRequest().getHeaders().put(ClientConstants.HEADER_X_AUTH_TOKEN, OSClientSession.getCurrent().getTokenId());
64-
return invokeRequest(command.incrementRetriesAndReturn());
62+
try
63+
{
64+
OSAuthenticator.reAuthenticate();
65+
command.getRequest().getHeaders().put(ClientConstants.HEADER_X_AUTH_TOKEN, OSClientSession.getCurrent().getTokenId());
66+
return invokeRequest(command.incrementRetriesAndReturn());
67+
}
68+
finally {
69+
response.close();
70+
}
6571
}
6672
return response;
6773
}

0 commit comments

Comments
 (0)