Keycloak-14726 - release connections after fetching the OIDC-Config

This commit is contained in:
Gregor Tudan 2020-07-10 08:34:59 +02:00 committed by Pedro Igor
parent 1441e5d6f8
commit 5255336be2

View file

@ -20,6 +20,7 @@ package org.keycloak.adapters;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.util.EntityUtils;
import org.jboss.logging.Logger;
import org.keycloak.adapters.authentication.ClientCredentialsProvider;
import org.keycloak.adapters.authorization.PolicyEnforcer;
@ -216,12 +217,16 @@ public class KeycloakDeployment {
HttpGet request = new HttpGet(discoveryUrl);
request.addHeader("accept", "application/json");
HttpResponse response = getClient().execute(request);
if (response.getStatusLine().getStatusCode() != 200) {
throw new Exception(response.getStatusLine().getReasonPhrase());
try {
HttpResponse response = getClient().execute(request);
if (response.getStatusLine().getStatusCode() != 200) {
EntityUtils.consumeQuietly(response.getEntity());
throw new Exception(response.getStatusLine().getReasonPhrase());
}
return JsonSerialization.readValue(response.getEntity().getContent(), OIDCConfigurationRepresentation.class);
} finally {
request.releaseConnection();
}
return JsonSerialization.readValue(response.getEntity().getContent(), OIDCConfigurationRepresentation.class);
}
public RelativeUrlsUsed getRelativeUrls() {