[java-shib-shared] branch main updated: Fix up null component handling.

Scott Cantor cantor.2 at osu.edu
Mon Nov 28 18:59:00 UTC 2022


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

scantor pushed a commit to branch main
in repository java-shib-shared.

View the commit online:
http://git.shibboleth.net/view/?p=java-shib-shared.git;a=commit;h=597438ac5898f901dca09080737f3db972ce7b19

The following commit(s) were added to refs/heads/main by this push:
     new 597438ac Fix up null component handling.
597438ac is described below

commit 597438ac5898f901dca09080737f3db972ce7b19
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Mon Nov 28 13:58:57 2022 -0500

    Fix up null component handling.
---
 .../shibboleth/shared/service/reloadable/ProxiedFactoryBean.java | 7 +++----
 .../shibboleth/shared/service/reloadable/ReloadableScope.java    | 9 ++++-----
 2 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/shib-service/src/main/java/net/shibboleth/shared/service/reloadable/ProxiedFactoryBean.java b/shib-service/src/main/java/net/shibboleth/shared/service/reloadable/ProxiedFactoryBean.java
index 9301bf77..e47c0b16 100644
--- a/shib-service/src/main/java/net/shibboleth/shared/service/reloadable/ProxiedFactoryBean.java
+++ b/shib-service/src/main/java/net/shibboleth/shared/service/reloadable/ProxiedFactoryBean.java
@@ -30,6 +30,7 @@ import net.shibboleth.shared.annotation.constraint.NotEmpty;
 import net.shibboleth.shared.logic.Constraint;
 import net.shibboleth.shared.primitive.StringSupport;
 import net.shibboleth.shared.service.ReloadableService;
+import net.shibboleth.shared.service.ServiceException;
 import net.shibboleth.shared.service.ServiceableComponent;
 
 /**
@@ -113,10 +114,6 @@ public class ProxiedFactoryBean<T> extends AbstractFactoryBean<T> {
     @Nonnull protected T createInstance() throws Exception {
         
         try (final ServiceableComponent<ApplicationContext> component = contextService.getServiceableComponent()) {
-            if (component == null) {
-                throw new BeanCreationException("ApplicationContext not available");
-            }
-        
             String name = beanName;
             if (name != null) {
                 try {
@@ -131,6 +128,8 @@ public class ProxiedFactoryBean<T> extends AbstractFactoryBean<T> {
             }
             
             return component.getComponent().getBean(beanType);
+        } catch (final ServiceException e) {
+            throw new BeanCreationException("ApplicationContext not available", e);
         }
     }
    
diff --git a/shib-service/src/main/java/net/shibboleth/shared/service/reloadable/ReloadableScope.java b/shib-service/src/main/java/net/shibboleth/shared/service/reloadable/ReloadableScope.java
index 8440c984..53d6d309 100644
--- a/shib-service/src/main/java/net/shibboleth/shared/service/reloadable/ReloadableScope.java
+++ b/shib-service/src/main/java/net/shibboleth/shared/service/reloadable/ReloadableScope.java
@@ -24,6 +24,7 @@ import net.shibboleth.shared.annotation.ParameterName;
 import net.shibboleth.shared.annotation.constraint.NotEmpty;
 import net.shibboleth.shared.logic.Constraint;
 import net.shibboleth.shared.service.ReloadableService;
+import net.shibboleth.shared.service.ServiceException;
 import net.shibboleth.shared.service.ServiceableComponent;
 
 import org.slf4j.Logger;
@@ -62,11 +63,9 @@ public class ReloadableScope implements Scope {
     @Nonnull public Object get(@Nonnull final String name, @Nonnull final ObjectFactory<?> objectFactory) {
         log.debug("Accessing reloadable bean instance '{}'", name);
         try (final ServiceableComponent<ApplicationContext> component = reloadableService.getServiceableComponent()) {
-            if (component != null) {
-                return component.getComponent().getBean(name);
-            } else {
-                throw new IllegalStateException("Reloadable bean context is unavailable");
-            }
+            return component.getComponent().getBean(name);
+        } catch (final ServiceException e) {
+            throw new IllegalStateException("Reloadable bean context is unavailable", e);
         }
     }
 

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


More information about the commits mailing list