[java-shib-profile] branch main updated: Squash some nullness

Rod Widdowson rdw at steadingsoftware.com
Thu Jul 25 09:19:31 UTC 2024


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

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

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

The following commit(s) were added to refs/heads/main by this push:
     new ae9de33  Squash some nullness
ae9de33 is described below

commit ae9de339e611a094db4efb4ddc13c8805403430d
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Thu Jul 25 10:02:41 2024 +0100

    Squash some nullness
---
 .../shibboleth/profile/module/AbstractModule.java    | 20 ++++++++++++--------
 .../profile/module/PropertyDrivenModule.java         | 13 ++++++++-----
 .../profile/plugin/PropertyDrivenPlugin.java         |  8 +++++---
 3 files changed, 25 insertions(+), 16 deletions(-)

diff --git a/shib-profile-api/src/main/java/net/shibboleth/profile/module/AbstractModule.java b/shib-profile-api/src/main/java/net/shibboleth/profile/module/AbstractModule.java
index 597cf66..aa55bb8 100644
--- a/shib-profile-api/src/main/java/net/shibboleth/profile/module/AbstractModule.java
+++ b/shib-profile-api/src/main/java/net/shibboleth/profile/module/AbstractModule.java
@@ -121,12 +121,15 @@ public abstract class AbstractModule implements Module {
             if (moduleContext.getInstallLocation().startsWith(ResourceUtils.CLASSPATH_URL_PREFIX)) {
                 final ClassPathResource cp;
                 if (moduleContext.getInstallLocation().equals(ResourceUtils.CLASSPATH_URL_PREFIX)) {
-                    cp = new ClassPathResource(resource.getDestination().toString());
+                    final String resourceString = resource.getDestination().toString();
+                        assert resourceString != null;
+                    cp = new ClassPathResource(resourceString);
                 } else {
-                    cp = (ClassPathResource) new ClassPathResource(
-                            moduleContext.getInstallLocation().substring(
-                                    ResourceUtils.CLASSPATH_URL_PREFIX.length())).createRelative(
-                                            resource.getDestination().toString());
+                    final String resourceString = moduleContext.getInstallLocation().substring(
+                            ResourceUtils.CLASSPATH_URL_PREFIX.length());
+                    final String relString =resource.getDestination().toString(); 
+                        assert resourceString != null && relString != null;
+                    cp = (ClassPathResource) new ClassPathResource(resourceString).createRelative(relString);
                 }
                 
                 if (!cp.exists()) {
@@ -436,7 +439,9 @@ public abstract class AbstractModule implements Module {
                 final HttpGet request = new HttpGet(uri);
                 response = Constraint.isNotNull(moduleContext.getHttpClient(),
                         "HttpClient cannot be null").executeOpen(null, request, clientContext);
-                HttpClientSecuritySupport.checkTLSCredentialEvaluated(clientContext, request.getScheme());
+                final String scheme = request.getScheme();
+                assert scheme != null; 
+                HttpClientSecuritySupport.checkTLSCredentialEvaluated(clientContext, scheme);
                 if (response.getCode() != 200) {
                     throw new IOException("HTTP request was unsuccessful");
                 }
@@ -594,5 +599,4 @@ public abstract class AbstractModule implements Module {
         }
         
     }
-
-}
\ No newline at end of file
+}
diff --git a/shib-profile-api/src/main/java/net/shibboleth/profile/module/PropertyDrivenModule.java b/shib-profile-api/src/main/java/net/shibboleth/profile/module/PropertyDrivenModule.java
index 5b18657..6b090b3 100644
--- a/shib-profile-api/src/main/java/net/shibboleth/profile/module/PropertyDrivenModule.java
+++ b/shib-profile-api/src/main/java/net/shibboleth/profile/module/PropertyDrivenModule.java
@@ -128,7 +128,7 @@ public abstract class PropertyDrivenModule extends AbstractModule implements Mod
      */
     public PropertyDrivenModule(@Nullable final String version, @Nonnull final Class<? extends Module> claz)
             throws IOException, ModuleException {
-        this(version, claz.getResourceAsStream(DEFAULT_RESOURCE));
+        this(version, Constraint.isNotNull(claz.getResourceAsStream(DEFAULT_RESOURCE), "null resource stream"));
     }
     
     /**
@@ -187,8 +187,9 @@ public abstract class PropertyDrivenModule extends AbstractModule implements Mod
             moduleURL = StringSupport.trimOrNull(moduleProperties.getProperty(getId() + MODULE_URL_PROPERTY));
             pluginId = StringSupport.trimOrNull(moduleProperties.getProperty(getId() + MODULE_PLUGIN_PROPERTY));
             
-            locales = StringSupport.stringToList(
-                    moduleProperties.getProperty(getId() + MODULE_LANGS_PROPERTY, ""), ", ");
+            final String langs = moduleProperties.getProperty(getId() + MODULE_LANGS_PROPERTY, "");
+            assert langs != null;
+            locales = StringSupport.stringToList(langs, ", ");
             
             final Collection<BasicModuleResource> resources = new ArrayList<>();
             
@@ -252,7 +253,9 @@ public abstract class PropertyDrivenModule extends AbstractModule implements Mod
         if (moduleContext != null) {
             final String best = Locale.lookupTag(moduleContext.getLanguageRanges(), locales);
             if (best != null && !best.equals(locales.get(0))) {
-                return moduleProperties.getProperty(getId() + MODULE_NAME_PROPERTY + "." + best, moduleName);
+                final String result = moduleProperties.getProperty(getId() + MODULE_NAME_PROPERTY + "." + best, moduleName);
+                assert result != null;
+                return result;
             }
         }
         return moduleName;
@@ -354,4 +357,4 @@ public abstract class PropertyDrivenModule extends AbstractModule implements Mod
         return results;
     }
     
-}
\ No newline at end of file
+}
diff --git a/shib-profile-api/src/main/java/net/shibboleth/profile/plugin/PropertyDrivenPlugin.java b/shib-profile-api/src/main/java/net/shibboleth/profile/plugin/PropertyDrivenPlugin.java
index b855662..3a71c40 100644
--- a/shib-profile-api/src/main/java/net/shibboleth/profile/plugin/PropertyDrivenPlugin.java
+++ b/shib-profile-api/src/main/java/net/shibboleth/profile/plugin/PropertyDrivenPlugin.java
@@ -93,7 +93,7 @@ public abstract class PropertyDrivenPlugin<T extends Module> extends AbstractPlu
      * @throws PluginException if the plugin is not in a valid state
      */
     public PropertyDrivenPlugin(@Nonnull final Class<? extends Plugin<T>> claz) throws IOException, PluginException {
-        this(claz.getResourceAsStream(DEFAULT_RESOURCE));
+        this(Constraint.isNotNull(claz.getResourceAsStream(DEFAULT_RESOURCE), "InoutStream cannot be null"));
     }
     
     /**
@@ -166,8 +166,10 @@ public abstract class PropertyDrivenPlugin<T extends Module> extends AbstractPlu
         
         updateURLs = CollectionSupport.copyToList(urls);
         
-        requiredModules = CollectionSupport.copyToSet(StringSupport.normalizeStringCollection(
-                StringSupport.stringToList(pluginProperties.getProperty(PLUGIN_REQ_MODULES_PROPERTY, ""), ",")));
+		final String propVals = pluginProperties.getProperty(PLUGIN_REQ_MODULES_PROPERTY, "");
+		assert propVals != null;
+
+        requiredModules = CollectionSupport.copyToSet(StringSupport.normalizeStringCollection(StringSupport.stringToList(propVals, ",")));
 
         log.debug("Plugin {} loaded", getPluginId());
     }

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


More information about the commits mailing list