[ 
https://issues.apache.org/jira/browse/COLLECTIONS-886?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Partha Paul resolved COLLECTIONS-886.
-------------------------------------
    Resolution: Fixed

This issue was fixed in the afforementioned pr, which was merged in the main.

> [javadoc] CompositeSet.addComposited(Set) does not throw NullPointerException 
> when null is passed
> -------------------------------------------------------------------------------------------------
>
>                 Key: COLLECTIONS-886
>                 URL: https://issues.apache.org/jira/browse/COLLECTIONS-886
>             Project: Commons Collections
>          Issue Type: Bug
>    Affects Versions: 4.5.0
>         Environment: commons-collections: 4.5.0 (and previous versions)
> java: 17.0.12
>            Reporter: Partha Paul
>            Priority: Major
>              Labels: docuentation, documentation-update, implementation
>
> The Javadoc for {{CompositeSet.addComposited(Set)}} explicitly states that a 
> {{NullPointerException}} should be thrown when the {{set}} parameter is 
> {{{}null{}}}. However, the current implementation contains a null guard ( 
> {{if set != null}} ) that silently ignores null input and doesn't throw an 
> exception.
> h5. Javadoc (Current) contains
> {code:java}
> @throws NullPointerException if {@code set} is null
> {code}
> h5. Implementation (Current)
> {code:java}
> public synchronized void addComposited(final Set<E> set) {
>        if (set != null) {
>        ...
>        all.add(set);
>     }
> }
> {code}
> There also exist a test code 
> {{org.apache.commons.collections4.set.CompositeSetTest.testAddComposited}} 
> which adds {{null}} to the {{CompositeSet}} using this method.
> h5. Steps to Reproduce
> {code:java}
> @Test
> void testNullPointerExceptionOnAddCompositedWithNullSet() {
>      CompositeSet<String> set = new CompositeSet<>(new HashSet<>());
>      assertThrows(NullPointerException.class, () -> set.addComposited(null));
> }
> {code}
> The test above will fail because no {{NullPointerException}} is thrown.
> Happy to submit pr by fixing the javadoc by removing the 
> {{NullPointerException}} clause!



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to