Uploaded image for project: 'Commons Collections'
  1. Commons Collections
  2. COLLECTIONS-554

NullPointerException in CollectionUtils.partition

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Invalid
    • Affects Version/s: 4.1
    • Fix Version/s: None
    • Component/s: Collection
    • Labels:
      None

      Description

      NullPointerException (NPE) is not suitably handled in CollectionUtils.partition. With a nullFactory, partitions.get(numberOfPredicates) can be null at line partitions.get(numberOfPredicates).add(element);.

      Stack trace:

      test(Test)java.lang.NullPointerException
              at org.apache.commons.collections4.CollectionUtils.partition(CollectionUtils.java:1187)
              at Test.test(Test.java:18)
      

      Test case:

      public void test() {
        Collection input = CollectionUtils.permutations((java.util.Collection)new CircularFifoQueue(10));
        Factory factory = FactoryUtils.nullFactory();
        NullIsFalsePredicate p = new NullIsFalsePredicate(NullPredicate.nullPredicate());
        Predicate[] predicates = p.getPredicates();
        CollectionUtils.<java.lang.Object,java.util.Collection>partition((java.lang.Iterable)input, factory, predicates);
      }
      
      
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              mjkim0324 M Kim
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: