[java-opensaml] branch main updated: Drive-by non-null change

Rod Widdowson rdw at steadingsoftware.com
Thu Oct 17 12:21:06 UTC 2024


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

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

View the commit online:
http://git.shibboleth.net/view/?p=java-opensaml.git;a=commit;h=24629aee32602f9290d8cff359d085e426c3a96b

The following commit(s) were added to refs/heads/main by this push:
     new 24629aee3 Drive-by non-null change
24629aee3 is described below

commit 24629aee32602f9290d8cff359d085e426c3a96b
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Thu Oct 17 13:21:01 2024 +0100

    Drive-by non-null change
---
 .../src/main/java/org/opensaml/messaging/context/BaseContext.java | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/opensaml-messaging-api/src/main/java/org/opensaml/messaging/context/BaseContext.java b/opensaml-messaging-api/src/main/java/org/opensaml/messaging/context/BaseContext.java
index feabe0952..d6081eebc 100644
--- a/opensaml-messaging-api/src/main/java/org/opensaml/messaging/context/BaseContext.java
+++ b/opensaml-messaging-api/src/main/java/org/opensaml/messaging/context/BaseContext.java
@@ -200,7 +200,9 @@ public abstract class BaseContext implements Iterable<BaseContext> {
     @Deprecated(since = "5.0.0", forRemoval = false)
     @Nullable public BaseContext getSubcontext(@Nonnull @NotEmpty final String className, final boolean autocreate) {
         try {
-            return getSubcontext(Class.forName(className).asSubclass(BaseContext.class), autocreate);
+            final Class<? extends BaseContext> claz = Class.forName(className).asSubclass(BaseContext.class);
+            assert claz != null;
+            return getSubcontext(claz, autocreate);
         } catch (final ClassNotFoundException e) {
             
             // Check for a deprecated class name.
@@ -363,7 +365,9 @@ public abstract class BaseContext implements Iterable<BaseContext> {
      */
     @Nonnull protected <T extends BaseContext> T createSubcontext(@Nonnull final Class<T> clazz) {
         try {
-            return clazz.getConstructor().newInstance();
+            final T result = clazz.getConstructor().newInstance();
+            assert result != null;
+            return result;
         } catch (final SecurityException|NoSuchMethodException|IllegalArgumentException|InstantiationException|
                     IllegalAccessException|InvocationTargetException e) {
             log.error("Error creating subcontext: {}", e.getMessage());

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


More information about the commits mailing list