[java-oidc-common] branch main updated: Fix possible resource leak

Phil Smart philip.smart at jisc.ac.uk
Fri Apr 28 10:10:28 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=1b7301e86aab341624ed032d2086eb78c16da31e

The following commit(s) were added to refs/heads/main by this push:
     new 1b7301e  Fix possible resource leak
1b7301e is described below

commit 1b7301e86aab341624ed032d2086eb78c16da31e
Author: Phil Smart <philip.smart at jisc.ac.uk>
AuthorDate: Fri Apr 28 11:10:26 2023 +0100

    Fix possible resource leak
---
 .../oidc/metadata/cache/impl/DefaultFileLoadingStrategy.java        | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/oidc-common-metadata-impl/src/main/java/net/shibboleth/oidc/metadata/cache/impl/DefaultFileLoadingStrategy.java b/oidc-common-metadata-impl/src/main/java/net/shibboleth/oidc/metadata/cache/impl/DefaultFileLoadingStrategy.java
index 87e1307..f9e58c4 100644
--- a/oidc-common-metadata-impl/src/main/java/net/shibboleth/oidc/metadata/cache/impl/DefaultFileLoadingStrategy.java
+++ b/oidc-common-metadata-impl/src/main/java/net/shibboleth/oidc/metadata/cache/impl/DefaultFileLoadingStrategy.java
@@ -88,7 +88,11 @@ public class DefaultFileLoadingStrategy implements LoadingStrategy {
             if (context.getLastRefresh() == null || context.getLastUpdate() == null || 
                     metadataUpdateTime.isAfter(context.getLastRefresh())) {
                 log.debug("Returning the contents of {} as byte array", metadataFile.toPath());
-                return ResolverHelper.inputstreamToByteArray(new FileInputStream(metadataFile));
+                try (FileInputStream fileInput = new FileInputStream(metadataFile)){
+                    return ResolverHelper.inputstreamToByteArray(fileInput);
+                } catch (final Exception e) {
+                    throw new CacheLoadingException("Unable to read metadata file", e);
+                }
             }
             return null;
         } catch (final Exception e) {

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list