[java-identity-provider] branch main updated: JSSH-5 ServiceableComponent should implement AutoClose

Rod Widdowson rdw at steadingsoftware.com
Thu Sep 29 13:46:09 UTC 2022


This is an automated email from the git hooks/post-receive script.

rdw pushed a commit to branch main
in repository java-identity-provider.

View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=998a3e2030459f710e08db1cfc1cdcd78760f22d

The following commit(s) were added to refs/heads/main by this push:
     new 998a3e203 JSSH-5 ServiceableComponent should implement AutoClose
998a3e203 is described below

commit 998a3e2030459f710e08db1cfc1cdcd78760f22d
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Thu Sep 29 14:45:42 2022 +0100

    JSSH-5 ServiceableComponent should implement AutoClose
    
    https://shibboleth.atlassian.net/browse/JSSH-5
    
    Use auto close rather than manually unpinning things.
---
 .../impl/EncryptionCredentialsResolver.java        |  8 +-------
 ...ReloadingRelyingPartyConfigurationResolver.java | 24 +++-------------------
 .../impl/SigningCredentialsResolver.java           |  8 +-------
 3 files changed, 5 insertions(+), 35 deletions(-)

diff --git a/idp-profile-impl/src/main/java/net/shibboleth/idp/relyingparty/impl/EncryptionCredentialsResolver.java b/idp-profile-impl/src/main/java/net/shibboleth/idp/relyingparty/impl/EncryptionCredentialsResolver.java
index f41dad538..3e5b48f52 100644
--- a/idp-profile-impl/src/main/java/net/shibboleth/idp/relyingparty/impl/EncryptionCredentialsResolver.java
+++ b/idp-profile-impl/src/main/java/net/shibboleth/idp/relyingparty/impl/EncryptionCredentialsResolver.java
@@ -84,9 +84,7 @@ public class EncryptionCredentialsResolver implements CredentialResolver, Identi
     /** {@inheritDoc} */
     @Nonnull public Iterable<Credential> resolve(@Nullable final CriteriaSet criteria) 
             throws ResolverException {
-        ServiceableComponent<RelyingPartyConfigurationResolver> component = null;
-        try {
-            component = service.getServiceableComponent();
+        try(final ServiceableComponent<RelyingPartyConfigurationResolver> component = service.getServiceableComponent()) {
             if (null == component) {
                 log.error("EncryptionCredentialsResolver '{}': error looking up relying party configuration service:"
                         + " Invalid configuration.", getId());
@@ -99,10 +97,6 @@ public class EncryptionCredentialsResolver implements CredentialResolver, Identi
                 log.trace("Did NOT see expected instance of DefaultRelyingPartyConfigurationResolver");
                 return Collections.emptyList();
             }
-        } finally {
-            if (null != component) {
-                component.unpinComponent();
-            }
         }
         return null;
     }
diff --git a/idp-profile-impl/src/main/java/net/shibboleth/idp/relyingparty/impl/ReloadingRelyingPartyConfigurationResolver.java b/idp-profile-impl/src/main/java/net/shibboleth/idp/relyingparty/impl/ReloadingRelyingPartyConfigurationResolver.java
index bbf391913..dcec734fc 100644
--- a/idp-profile-impl/src/main/java/net/shibboleth/idp/relyingparty/impl/ReloadingRelyingPartyConfigurationResolver.java
+++ b/idp-profile-impl/src/main/java/net/shibboleth/idp/relyingparty/impl/ReloadingRelyingPartyConfigurationResolver.java
@@ -71,9 +71,7 @@ public class ReloadingRelyingPartyConfigurationResolver extends AbstractIdentifi
     @Override @Nonnull @NonnullElements public Iterable<RelyingPartyConfiguration> resolve(
             @Nullable final ProfileRequestContext context) throws ResolverException {
         checkComponentActive();
-        ServiceableComponent<RelyingPartyConfigurationResolver> component = null;
-        try {
-            component = service.getServiceableComponent();
+        try (final ServiceableComponent<RelyingPartyConfigurationResolver> component = service.getServiceableComponent()) {
             if (null == component) {
                 log.error("RelyingPartyResolver '{}': error looking up Relying Party: Invalid configuration", getId());
             } else {
@@ -86,10 +84,6 @@ public class ReloadingRelyingPartyConfigurationResolver extends AbstractIdentifi
             }
         } catch (final ResolverException e) {
             log.error("RelyingPartyResolver '{}': error in resolution", getId(), e);
-        } finally {
-            if (null != component) {
-                component.unpinComponent();
-            }
         }
         return Collections.emptySet();
     }
@@ -98,9 +92,7 @@ public class ReloadingRelyingPartyConfigurationResolver extends AbstractIdentifi
     @Override @Nullable public RelyingPartyConfiguration resolveSingle(@Nullable final ProfileRequestContext context)
             throws ResolverException {
         checkComponentActive();
-        ServiceableComponent<RelyingPartyConfigurationResolver> component = null;
-        try {
-            component = service.getServiceableComponent();
+        try (final ServiceableComponent<RelyingPartyConfigurationResolver> component = service.getServiceableComponent()){
             if (null == component) {
                 log.error("RelyingPartyResolver '{}': error looking up Relying Party: Invalid configuration", getId());
             } else {
@@ -109,10 +101,6 @@ public class ReloadingRelyingPartyConfigurationResolver extends AbstractIdentifi
             }
         } catch (final ResolverException e) {
             log.error("RelyingPartyResolver '{}': error in resolution", getId(), e);
-        } finally {
-            if (null != component) {
-                component.unpinComponent();
-            }
         }
         return null;
     }
@@ -120,9 +108,7 @@ public class ReloadingRelyingPartyConfigurationResolver extends AbstractIdentifi
     /** {@inheritDoc} */
     @Override public SecurityConfiguration getDefaultSecurityConfiguration(final String profileId) {
         checkComponentActive();
-        ServiceableComponent<RelyingPartyConfigurationResolver> component = null;
-        try {
-            component = service.getServiceableComponent();
+        try (final ServiceableComponent<RelyingPartyConfigurationResolver> component = service.getServiceableComponent()){
             if (null == component) {
                 log.error("RelyingPartyResolver '{}': error looking up default security config:"
                         + " Invalid configuration", getId());
@@ -130,10 +116,6 @@ public class ReloadingRelyingPartyConfigurationResolver extends AbstractIdentifi
                 final RelyingPartyConfigurationResolver resolver = component.getComponent();
                 return resolver.getDefaultSecurityConfiguration(profileId);
             }
-        } finally {
-            if (null != component) {
-                component.unpinComponent();
-            }
         }
         return null;
     }
diff --git a/idp-profile-impl/src/main/java/net/shibboleth/idp/relyingparty/impl/SigningCredentialsResolver.java b/idp-profile-impl/src/main/java/net/shibboleth/idp/relyingparty/impl/SigningCredentialsResolver.java
index 107539a8c..59d813d7e 100644
--- a/idp-profile-impl/src/main/java/net/shibboleth/idp/relyingparty/impl/SigningCredentialsResolver.java
+++ b/idp-profile-impl/src/main/java/net/shibboleth/idp/relyingparty/impl/SigningCredentialsResolver.java
@@ -84,9 +84,7 @@ public class SigningCredentialsResolver implements CredentialResolver, Identifia
     /** {@inheritDoc} */
     @Nonnull public Iterable<Credential> resolve(@Nullable final CriteriaSet criteria) 
             throws ResolverException {
-        ServiceableComponent<RelyingPartyConfigurationResolver> component = null;
-        try {
-            component = service.getServiceableComponent();
+        try (final ServiceableComponent<RelyingPartyConfigurationResolver> component = service.getServiceableComponent()) {
             if (null == component) {
                 log.error("SigningCredentialsResolver '{}': error looking up relying party configuration service:"
                         + " Invalid configuration.", getId());
@@ -99,10 +97,6 @@ public class SigningCredentialsResolver implements CredentialResolver, Identifia
                 log.trace("Did NOT see expected instance of DefaultRelyingPartyConfigurationResolver");
                 return Collections.emptyList();
             }
-        } finally {
-            if (null != component) {
-                component.unpinComponent();
-            }
         }
         return null;
     }

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


More information about the commits mailing list