diff --git a/msal/src/main/java/com/microsoft/identity/client/PublicClientApplication.java b/msal/src/main/java/com/microsoft/identity/client/PublicClientApplication.java index d5f09e36a..c184305e4 100644 --- a/msal/src/main/java/com/microsoft/identity/client/PublicClientApplication.java +++ b/msal/src/main/java/com/microsoft/identity/client/PublicClientApplication.java @@ -1066,6 +1066,23 @@ private static PublicClientApplicationConfiguration loadConfiguration(InputStrea throw new IllegalArgumentException("Unable to open provided configuration file.", e); } } + finally { + try { + configStream.close(); + } catch (IOException e) { + if (isDefaultConfiguration) { + com.microsoft.identity.common.internal.logging.Logger.warn( + TAG + "loadConfiguration", + "Unable to close default configuration file. This can cause memory leak." + ); + } else { + com.microsoft.identity.common.internal.logging.Logger.warn( + TAG + "loadConfiguration", + "Unable to close provided configuration file. This can cause memory leak." + ); + } + } + } final String config = new String(buffer); final Gson gson = getGsonForLoadingConfiguration(); @@ -1203,4 +1220,4 @@ public void onCancel() { private OAuth2TokenCache getOAuth2TokenCache() { return initCommonCache(mPublicClientConfiguration.getAppContext()); } -} \ No newline at end of file +}