Skip to content

Commit

Permalink
Close resources after reading the config file. (#520)
Browse files Browse the repository at this point in the history
* Close resources after read.

* Warn instead of verbose
  • Loading branch information
Anna Kocheshkova authored and iambmelt committed Feb 5, 2019
1 parent 8925680 commit 7941fda
Showing 1 changed file with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -1203,4 +1220,4 @@ public void onCancel() {
private OAuth2TokenCache<?, ?, ?> getOAuth2TokenCache() {
return initCommonCache(mPublicClientConfiguration.getAppContext());
}
}
}

0 comments on commit 7941fda

Please sign in to comment.