[java-shib-shared] 02/03: IDP-2069 Null handling task https://shibboleth.atlassian.net/browse/IDP-2069 Clean up some more warnings
Rod Widdowson
rdw at steadingsoftware.com
Fri Apr 28 15:21:18 UTC 2023
This is an automated email from the git hooks/post-receive script.
rdw 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=8770abe9586f5af460779ca3c53f88536e04ad9f
commit 8770abe9586f5af460779ca3c53f88536e04ad9f
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Fri Apr 28 16:20:35 2023 +0100
IDP-2069 Null handling task
https://shibboleth.atlassian.net/browse/IDP-2069
Clean up some more warnings
---
.../shibboleth/shared/collection/ClassToInstanceMultiMap.java | 2 +-
.../main/java/net/shibboleth/shared/collection/LazyList.java | 3 +--
.../main/java/net/shibboleth/shared/collection/LazyMap.java | 2 +-
.../main/java/net/shibboleth/shared/collection/LazySet.java | 2 +-
.../java/net/shibboleth/shared/logic/BiFunctionSupport.java | 4 +++-
.../java/net/shibboleth/shared/logic/BiPredicateSupport.java | 10 ++++++----
.../main/java/net/shibboleth/shared/logic/FunctionSupport.java | 4 +++-
.../shibboleth/shared/collection/ValueTypeIndexedMapTest.java | 6 ++----
8 files changed, 18 insertions(+), 15 deletions(-)
diff --git a/shib-support/src/main/java/net/shibboleth/shared/collection/ClassToInstanceMultiMap.java b/shib-support/src/main/java/net/shibboleth/shared/collection/ClassToInstanceMultiMap.java
index 2228d3af..373165f8 100644
--- a/shib-support/src/main/java/net/shibboleth/shared/collection/ClassToInstanceMultiMap.java
+++ b/shib-support/src/main/java/net/shibboleth/shared/collection/ClassToInstanceMultiMap.java
@@ -124,7 +124,7 @@ public class ClassToInstanceMultiMap<B> {
if (indexedValues == null) {
return CollectionSupport.emptyList();
}
- return Collections.unmodifiableList(indexedValues);
+ return CollectionSupport.copyToList(indexedValues);
}
/**
diff --git a/shib-support/src/main/java/net/shibboleth/shared/collection/LazyList.java b/shib-support/src/main/java/net/shibboleth/shared/collection/LazyList.java
index a5107804..796fb4d8 100644
--- a/shib-support/src/main/java/net/shibboleth/shared/collection/LazyList.java
+++ b/shib-support/src/main/java/net/shibboleth/shared/collection/LazyList.java
@@ -20,7 +20,6 @@ package net.shibboleth.shared.collection;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
@@ -46,7 +45,7 @@ public class LazyList<ElementType> implements List<ElementType>, Serializable {
public boolean add(final ElementType item) {
if (delegate.isEmpty()) {
// TODO: allow null?
- delegate = Collections.singletonList(item);
+ delegate = CollectionSupport.singletonList(item);
return true;
}
diff --git a/shib-support/src/main/java/net/shibboleth/shared/collection/LazyMap.java b/shib-support/src/main/java/net/shibboleth/shared/collection/LazyMap.java
index 843fd915..7bfeac39 100644
--- a/shib-support/src/main/java/net/shibboleth/shared/collection/LazyMap.java
+++ b/shib-support/src/main/java/net/shibboleth/shared/collection/LazyMap.java
@@ -83,7 +83,7 @@ public class LazyMap<KeyType, ValueType> implements Map<KeyType, ValueType>, Ser
public ValueType put(final KeyType key, final ValueType value) {
if (delegate.isEmpty()) {
// TODO: allow nulls?
- delegate = Collections.singletonMap(key, value);
+ delegate = CollectionSupport.singletonMap(key, value);
return null;
}
diff --git a/shib-support/src/main/java/net/shibboleth/shared/collection/LazySet.java b/shib-support/src/main/java/net/shibboleth/shared/collection/LazySet.java
index 4d25e387..1a526bcc 100644
--- a/shib-support/src/main/java/net/shibboleth/shared/collection/LazySet.java
+++ b/shib-support/src/main/java/net/shibboleth/shared/collection/LazySet.java
@@ -45,7 +45,7 @@ public class LazySet<ElementType> implements Set<ElementType>, Serializable {
public boolean add(final ElementType element) {
if (delegate.isEmpty()) {
// TODO: allow null?
- delegate = Collections.singleton(element);
+ delegate = CollectionSupport.singleton(element);
return true;
}
diff --git a/shib-support/src/main/java/net/shibboleth/shared/logic/BiFunctionSupport.java b/shib-support/src/main/java/net/shibboleth/shared/logic/BiFunctionSupport.java
index 104b98bb..ed87cced 100644
--- a/shib-support/src/main/java/net/shibboleth/shared/logic/BiFunctionSupport.java
+++ b/shib-support/src/main/java/net/shibboleth/shared/logic/BiFunctionSupport.java
@@ -70,7 +70,9 @@ public final class BiFunctionSupport {
@Nonnull public static <A,B,C,D> BiFunction<A,B,D> compose(
@Nonnull @ParameterName(name="g") final Function<? super C,? extends D> g,
@Nonnull @ParameterName(name="f") final BiFunction<A,B,? extends C> f) {
- return f.andThen(g);
+ final BiFunction<A,B,D> result = f.andThen(g);
+ assert result != null;
+ return result;
}
/**
diff --git a/shib-support/src/main/java/net/shibboleth/shared/logic/BiPredicateSupport.java b/shib-support/src/main/java/net/shibboleth/shared/logic/BiPredicateSupport.java
index 3fd1c6d4..d5836490 100644
--- a/shib-support/src/main/java/net/shibboleth/shared/logic/BiPredicateSupport.java
+++ b/shib-support/src/main/java/net/shibboleth/shared/logic/BiPredicateSupport.java
@@ -150,8 +150,9 @@ public final class BiPredicateSupport {
*/
@Nonnull public static <T,U> BiPredicate<T,U> and(@Nonnull final BiPredicate<T,U> first,
@Nonnull final BiPredicate<? super T,? super U> second) {
-
- return first.and(second);
+ final BiPredicate<T,U> result = first.and(second);
+ assert result != null;
+ return result;
}
/**
@@ -233,8 +234,9 @@ public final class BiPredicateSupport {
*/
@Nonnull public static <T,U> BiPredicate<T,U> or(@Nonnull final BiPredicate<T,U> first,
@Nonnull final BiPredicate<? super T,? super U> second) {
-
- return first.or(second);
+ final BiPredicate<T,U> result = first.or(second);
+ assert result != null;
+ return result;
}
}
\ No newline at end of file
diff --git a/shib-support/src/main/java/net/shibboleth/shared/logic/FunctionSupport.java b/shib-support/src/main/java/net/shibboleth/shared/logic/FunctionSupport.java
index d6a34fe5..8db4f9d8 100644
--- a/shib-support/src/main/java/net/shibboleth/shared/logic/FunctionSupport.java
+++ b/shib-support/src/main/java/net/shibboleth/shared/logic/FunctionSupport.java
@@ -64,7 +64,9 @@ public final class FunctionSupport {
@Nonnull public static <A,B,C> Function<A,C> compose(
@Nonnull @ParameterName(name="g") final Function<? super B,? extends C> g,
@Nonnull @ParameterName(name="f") final Function<A,? extends B> f) {
- return f.andThen(g);
+ final Function<A,C> result = f.andThen(g);
+ assert result!=null;
+ return result;
}
/**
diff --git a/shib-support/src/test/java/net/shibboleth/shared/collection/ValueTypeIndexedMapTest.java b/shib-support/src/test/java/net/shibboleth/shared/collection/ValueTypeIndexedMapTest.java
index 27634002..73781290 100644
--- a/shib-support/src/test/java/net/shibboleth/shared/collection/ValueTypeIndexedMapTest.java
+++ b/shib-support/src/test/java/net/shibboleth/shared/collection/ValueTypeIndexedMapTest.java
@@ -17,8 +17,6 @@
package net.shibboleth.shared.collection;
-import java.util.Arrays;
-
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -32,7 +30,7 @@ public class ValueTypeIndexedMapTest {
/** Set up state for this test. */
@BeforeMethod public void setUp() {
map = new ValueTypeIndexedMap<>();
- map.setTypes(Arrays.asList(new Class<?>[] {Integer.class, String.class}));
+ map.setTypes(CollectionSupport.arrayAsList(new Class<?>[] {Integer.class, String.class}));
map.rebuildIndex();
}
@@ -108,7 +106,7 @@ public class ValueTypeIndexedMapTest {
/* Test equals and hashcode */
@Test public void testEqualsHashCode() {
ValueTypeIndexedMap<String, Object> other = new ValueTypeIndexedMap<>();
- other.setTypes(Arrays.asList(new Class<?>[] {Integer.class}));
+ other.setTypes(CollectionSupport.arrayAsList(new Class<?>[] {Integer.class}));
other.rebuildIndex();
Assert.assertEquals(map, other, "Empty maps should be the same");
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list