commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thomas Neidhart (JIRA)" <>
Subject [jira] [Resolved] (COLLECTIONS-513) NullPointerException in SwitchTransformer.transform
Date Thu, 10 Apr 2014 20:30:16 GMT


Thomas Neidhart resolved COLLECTIONS-513.

    Resolution: Invalid

This is not a bug.

The constructor of SwitchTransformer states that the array of predicates must not contain
null values:

     * @param predicates  array of predicates, cloned, no nulls

but the provided array of predicates is an array with one null value.

I think the way these tests are created are flawed:

        org.apache.commons.collections4.set.CompositeSet var1 = new org.apache.commons.collections4.set.CompositeSet(
        org.apache.commons.collections4.functors.UniquePredicate var2 = new org.apache.commons.collections4.functors.UniquePredicate();
        org.apache.commons.collections4.Predicate[] var3 = new org.apache.commons.collections4.Predicate[]
{ var2 };
        java.lang.Object[] var4 = var1.toArray((java.lang.Object[]) var3);

Here var1 is an empty set, whose contents are copied into an object array var4. But the toArray()
method is called with an non-empty array, which will be modified by the toArray() call and
result in this 1-element array with a null value.

I fail to see what this tries to test, as the result of this operation will be in any case

> NullPointerException in SwitchTransformer.transform
> ---------------------------------------------------
>                 Key: COLLECTIONS-513
>                 URL:
>             Project: Commons Collections
>          Issue Type: Bug
>          Components: Functor
>    Affects Versions: 4.0
>         Environment: Mac OS 10.9, Java 6 and Java 7
>            Reporter: Cyrille Artho
>         Attachments:
> A relatively complex test case generated by Randoop results in a NullPointerException
in SwitchTransformer.transform.
> I'm not sure if this is an incorrect usage of the method, or if it is a real bug.

This message was sent by Atlassian JIRA

View raw message