[java-oidc-common] branch main updated: Return an empty list instead of null on metadata value lookup

Phil Smart philip.smart at jisc.ac.uk
Thu Apr 27 16:11:41 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=61fdeb1046f6af32572cd9bee11e017e13d2e6c6

The following commit(s) were added to refs/heads/main by this push:
     new 61fdeb1  Return an empty list instead of null on metadata value lookup
61fdeb1 is described below

commit 61fdeb1046f6af32572cd9bee11e017e13d2e6c6
Author: Phil Smart <philip.smart at jisc.ac.uk>
AuthorDate: Thu Apr 27 17:11:39 2023 +0100

    Return an empty list instead of null on metadata value lookup
---
 .../navigate/ProviderMetadataStringValuesLookupFunction.java  | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/oidc-common-profile-api/src/main/java/net/shibboleth/oidc/profile/config/navigate/ProviderMetadataStringValuesLookupFunction.java b/oidc-common-profile-api/src/main/java/net/shibboleth/oidc/profile/config/navigate/ProviderMetadataStringValuesLookupFunction.java
index 96fba44..aaef502 100644
--- a/oidc-common-profile-api/src/main/java/net/shibboleth/oidc/profile/config/navigate/ProviderMetadataStringValuesLookupFunction.java
+++ b/oidc-common-profile-api/src/main/java/net/shibboleth/oidc/profile/config/navigate/ProviderMetadataStringValuesLookupFunction.java
@@ -17,6 +17,7 @@
 
 package net.shibboleth.oidc.profile.config.navigate;
 
+import java.util.Collections;
 import java.util.List;
 import java.util.function.Function;
 import java.util.stream.Collectors;
@@ -33,7 +34,7 @@ import net.shibboleth.utilities.java.support.annotation.ParameterName;
 import net.shibboleth.utilities.java.support.logic.Constraint;
 
 /**
- * Fetches the values for the configured key as {@link String}. May return {@code null} and *not* an empty list 
+ * Fetches the values for the configured key as {@link String}. May return an empty list 
  * if the value is not found or the given {@link OIDCProviderMetadata} is {@code null}.
  */
 public class ProviderMetadataStringValuesLookupFunction implements Function<OIDCProviderMetadata, List<String>> {
@@ -55,16 +56,16 @@ public class ProviderMetadataStringValuesLookupFunction implements Function<OIDC
 
     /** {@inheritDoc} */
     @Override
-    @Nullable public List<String> apply(@Nullable final OIDCProviderMetadata metadata) {
+    @Nonnull public List<String> apply(@Nullable final OIDCProviderMetadata metadata) {
         if (metadata == null) {
             log.trace("No provider metadata available");
-            return null;
+            return Collections.emptyList();
         }
 
         final Object value = metadata.toJSONObject().get(keyName);
         if (value == null) {
             log.trace("No metadata value found for the key {}", keyName);
-            return null;
+            return Collections.emptyList();
         }
         if (value instanceof String) {
             return List.of(String.valueOf(value));
@@ -74,7 +75,7 @@ public class ProviderMetadataStringValuesLookupFunction implements Function<OIDC
         }
  
         log.trace("Metadata provided an unknown type for key '{}'", keyName);
-        return null;
+        return Collections.emptyList();
     }
 
 }

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


More information about the commits mailing list