From e04a60104db5be04cf2ce737d15cde03b0805050 Mon Sep 17 00:00:00 2001 From: prabathabey Date: Wed, 23 Dec 2015 16:55:35 +0530 Subject: [PATCH] Improve logging in RemoteDCRClient --- .../app/registration/util/RemoteDCRClient.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/src/main/java/org/wso2/carbon/dynamic/client/web/app/registration/util/RemoteDCRClient.java b/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/src/main/java/org/wso2/carbon/dynamic/client/web/app/registration/util/RemoteDCRClient.java index 9d5926db77..f17dd376a5 100644 --- a/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/src/main/java/org/wso2/carbon/dynamic/client/web/app/registration/util/RemoteDCRClient.java +++ b/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/src/main/java/org/wso2/carbon/dynamic/client/web/app/registration/util/RemoteDCRClient.java @@ -83,9 +83,10 @@ public class RemoteDCRClient { String responseString = EntityUtils.toString(responseData, DynamicClientWebAppRegistrationConstants. CharSets.CHARSET_UTF8); if (status != 201) { - throw new DynamicClientRegistrationException( - "Backend server error occurred while invoking DCR endpoint for " + - "registering service-provider for web-app : " + clientName); + String msg = "Backend server error occurred while invoking DCR endpoint for " + + "registering service-provider upon web-app : '" + clientName + "'; Server returned response '" + + responseString + "' with HTTP status code '" + status + "'"; + throw new DynamicClientRegistrationException(msg); } return getOAuthApplicationInfo(gson.fromJson(responseString, JsonElement.class)); } catch (URISyntaxException e) { @@ -102,7 +103,9 @@ public class RemoteDCRClient { " registering service-provider for web-app : " + clientName, e); } finally { - httpClient.close(); + if (httpClient != null) { + httpClient.close(); + } } } @@ -133,7 +136,9 @@ public class RemoteDCRClient { throw new DynamicClientRegistrationException("Exception occurred while constructing the URI for invoking " + "DCR endpoint for unregistering the web-app : " + appName, e); } finally { - httpClient.close(); + if (httpClient != null) { + httpClient.close(); + } } return false; }