[java-oidc-common] branch main updated: Fix possible resource leak
Phil Smart
philip.smart at jisc.ac.uk
Fri Apr 28 10:38:14 UTC 2023
This is an automated email from the git hooks/post-receive script.
philsmart pushed a commit to branch main
in repository java-oidc-common.
View the commit online:
http://git.shibboleth.net/view/?p=java-oidc-common.git;a=commit;h=5b71f081982e2ef78950edfd0223e648ffcd41a1
The following commit(s) were added to refs/heads/main by this push:
new 5b71f08 Fix possible resource leak
5b71f08 is described below
commit 5b71f081982e2ef78950edfd0223e648ffcd41a1
Author: Phil Smart <philip.smart at jisc.ac.uk>
AuthorDate: Fri Apr 28 11:38:12 2023 +0100
Fix possible resource leak
---
.../oidc/metadata/impl/AbstractFileOIDCEntityResolver.java | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/oidc-common-metadata-impl/src/main/java/net/shibboleth/oidc/metadata/impl/AbstractFileOIDCEntityResolver.java b/oidc-common-metadata-impl/src/main/java/net/shibboleth/oidc/metadata/impl/AbstractFileOIDCEntityResolver.java
index 19a621b..6bb1c14 100644
--- a/oidc-common-metadata-impl/src/main/java/net/shibboleth/oidc/metadata/impl/AbstractFileOIDCEntityResolver.java
+++ b/oidc-common-metadata-impl/src/main/java/net/shibboleth/oidc/metadata/impl/AbstractFileOIDCEntityResolver.java
@@ -59,7 +59,7 @@ public abstract class AbstractFileOIDCEntityResolver<Key extends Identifier, Val
*
* @throws IOException If the metedata cannot be loaded.
*/
- public AbstractFileOIDCEntityResolver(@Nonnull final Resource metadata) throws IOException {
+ protected AbstractFileOIDCEntityResolver(@Nonnull final Resource metadata) throws IOException {
setMetadataFile(metadata.getFile());
}
@@ -71,7 +71,7 @@ public abstract class AbstractFileOIDCEntityResolver<Key extends Identifier, Val
*
* @throws IOException If the metedata cannot be loaded.
*/
- public AbstractFileOIDCEntityResolver(@Nullable final Timer backgroundTaskTimer, @Nonnull final Resource metadata)
+ protected AbstractFileOIDCEntityResolver(@Nullable final Timer backgroundTaskTimer, @Nonnull final Resource metadata)
throws IOException {
super(backgroundTaskTimer);
setMetadataFile(metadata.getFile());
@@ -118,8 +118,10 @@ public abstract class AbstractFileOIDCEntityResolver<Key extends Identifier, Val
ResolverHelper.validateMetadataFile(metadataFile);
final Instant metadataUpdateTime = getMetadataUpdateTime();
if (getLastRefresh() == null || getLastUpdate() == null || metadataUpdateTime.isAfter(getLastRefresh())) {
- log.debug("Returning the contents of {} as byte array", metadataFile.toPath());
- return ResolverHelper.inputstreamToByteArray(new FileInputStream(metadataFile));
+ try(final FileInputStream fileInput = new FileInputStream(metadataFile)){
+ log.debug("Returning the contents of {} as byte array", metadataFile.toPath());
+ return ResolverHelper.inputstreamToByteArray(fileInput);
+ }
}
return null;
} catch (final IOException e) {
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list