[java-identity-provider] 02/02: IDP-1121 Explicitly preserve input order o IdPAttribute#setValues
Rod Widdowson
rdw at steadingsoftware.com
Mon Apr 22 05:04:22 EDT 2019
This is an automated email from the git hooks/post-receive script.
rdw pushed a commit to branch master
in repository java-identity-provider.
View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=292e1de9ce0d58609346ca4d1e5553b3edbb4ae1
commit 292e1de9ce0d58609346ca4d1e5553b3edbb4ae1
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Mon Apr 22 09:47:58 2019 +0100
IDP-1121 Explicitly preserve input order o IdPAttribute#setValues
https://issues.shibboleth.net/jira/browse/IDP-1121
By using stream we guarantee that if the input collection
says "Spliterator.ORDERED" then the internal list will be so ordered.
---
.../net/shibboleth/idp/attribute/IdPAttribute.java | 22 ++++------------------
1 file changed, 4 insertions(+), 18 deletions(-)
diff --git a/idp-attribute-api/src/main/java/net/shibboleth/idp/attribute/IdPAttribute.java b/idp-attribute-api/src/main/java/net/shibboleth/idp/attribute/IdPAttribute.java
index 452b741..5cdd380 100644
--- a/idp-attribute-api/src/main/java/net/shibboleth/idp/attribute/IdPAttribute.java
+++ b/idp-attribute-api/src/main/java/net/shibboleth/idp/attribute/IdPAttribute.java
@@ -24,7 +24,6 @@ import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
-import java.util.function.Function;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@@ -34,7 +33,6 @@ import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
import com.google.common.base.Predicates;
import com.google.common.collect.Collections2;
-import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
@@ -58,20 +56,6 @@ import net.shibboleth.utilities.java.support.primitive.StringSupport;
@NotThreadSafe
public class IdPAttribute implements Comparable<IdPAttribute>, Cloneable {
- /** helper {@link Function} to convert null to {@link EmptyAttributeValue}. */
- private static Function<IdPAttributeValue<?>, IdPAttributeValue<?>> convertNullValues
- = new Function<IdPAttributeValue<?>, IdPAttributeValue<?>>() {
-
- @Override
- public IdPAttributeValue<?> apply(final IdPAttributeValue<?> input) {
- if (null == input) {
- return new EmptyAttributeValue(EmptyType.NULL_VALUE);
- } else {
- return input;
- }
- }
- };
-
/** ID of this attribute. */
@Nonnull private final String id;
@@ -190,9 +174,11 @@ public class IdPAttribute implements Comparable<IdPAttribute>, Cloneable {
*/
public void setValues(@Nullable @NullableElements final Collection<? extends IdPAttributeValue<?>> newValues) {
if (newValues != null) {
- values = ImmutableList.copyOf(Collections2.transform(newValues, convertNullValues::apply));
+ values = List.of(newValues.stream().
+ map(e -> e==null? new EmptyAttributeValue(EmptyType.NULL_VALUE) :e).
+ toArray(IdPAttributeValue<?>[]::new));
} else {
- values = ImmutableList.of();
+ values = List.of();
}
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list