You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by ah...@apache.org on 2020/02/23 09:06:45 UTC

[isis] branch master updated: ISIS-2297: more coverage on _Sets, fixes possible NPE

This is an automated email from the ASF dual-hosted git repository.

ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git


The following commit(s) were added to refs/heads/master by this push:
     new e33e23e  ISIS-2297: more coverage on _Sets, fixes possible NPE
e33e23e is described below

commit e33e23e3878f059b05ee35a96f7e57eb507f1a9d
Author: Andi Huber <ah...@apache.org>
AuthorDate: Sun Feb 23 10:06:32 2020 +0100

    ISIS-2297: more coverage on _Sets, fixes possible NPE
---
 .../apache/isis/core/commons/internal/collections/_Collections.java  | 2 +-
 .../org/apache/isis/core/commons/internal/collections/_SetsTest.java | 5 +++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/core/commons/src/main/java/org/apache/isis/core/commons/internal/collections/_Collections.java b/core/commons/src/main/java/org/apache/isis/core/commons/internal/collections/_Collections.java
index fea05ec..ddb4dd6 100644
--- a/core/commons/src/main/java/org/apache/isis/core/commons/internal/collections/_Collections.java
+++ b/core/commons/src/main/java/org/apache/isis/core/commons/internal/collections/_Collections.java
@@ -243,7 +243,7 @@ public final class _Collections {
             Supplier<Collector<T, ?, R>> elementCollector) {
 
         if(iterable==null) {
-            return factory.apply(null);
+            return factory.apply(Collections.emptyList());
         }
         if(iterable instanceof Collection) {
             return factory.apply((Collection<T>) iterable);
diff --git a/core/commons/src/test/java/org/apache/isis/core/commons/internal/collections/_SetsTest.java b/core/commons/src/test/java/org/apache/isis/core/commons/internal/collections/_SetsTest.java
index e49617d..db09280 100644
--- a/core/commons/src/test/java/org/apache/isis/core/commons/internal/collections/_SetsTest.java
+++ b/core/commons/src/test/java/org/apache/isis/core/commons/internal/collections/_SetsTest.java
@@ -148,6 +148,7 @@ class _SetsTest {
      */
     @Test
     void testNewHashSetCollectionOfT() {
+        assertEquals(HashSet.class, _Sets.newHashSet(null).getClass());
         val set = _Sets.newHashSet(_Lists.of(3, 1, 2, 3, 3));
         assertEquals(HashSet.class, set.getClass());
         Samples.assertSetEquals(_Sets.of(1, 2, 3), set);
@@ -177,6 +178,7 @@ class _SetsTest {
      */
     @Test
     void testNewLinkedHashSetCollectionOfT() {
+        assertEquals(LinkedHashSet.class, _Sets.newLinkedHashSet(null).getClass());
         val set = _Sets.newLinkedHashSet(_Lists.of(3, 1, 2, 3, 3));
         assertEquals(LinkedHashSet.class, set.getClass());
         Samples.assertListEquals(_Lists.of(3, 1, 2), set);
@@ -235,6 +237,7 @@ class _SetsTest {
      */
     @Test
     void testNewCopyOnWriteArraySetCollectionOfT() {
+        assertEquals(CopyOnWriteArraySet.class, _Sets.newCopyOnWriteArraySet(null).getClass());
         val set = _Sets.newCopyOnWriteArraySet(_Lists.of(3, 1, 2, 3, 3));
         assertEquals(CopyOnWriteArraySet.class, set.getClass());
         Samples.assertListEquals(_Lists.of(3, 1, 2), set);
@@ -310,6 +313,7 @@ class _SetsTest {
     void testMinusSetOfTSetOfTSupplierOfSetOfT() {
         val set = _Sets.<Integer>minus(null, null, TreeSet::new);
         assertUnmodifiable(set);
+        Samples.assertSetEquals(_Sets.of(), _Sets.minus(_Sets.newTreeSet(_Sets.of(1)), null, TreeSet::new));
     }
 
     /**
@@ -319,6 +323,7 @@ class _SetsTest {
     void testMinusSortedSortedSetOfTSortedSetOfTSupplierOfSortedSetOfT() {
         val set = _Sets.<Integer>minusSorted(null, null, TreeSet::new);
         assertUnmodifiable(set);
+        Samples.assertListEquals(_Lists.of(1), _Sets.minusSorted(_Sets.newTreeSet(_Sets.of(1)), null, TreeSet::new));
     }
 
     /**