Skip to content

[COLLECTIONS_886] [javadoc] CompositeSet.addComposited(Set) does not throw NullPointerException when null is passed#675

Merged
garydgregory merged 1 commit intoapache:masterfrom
Partha-SUST16:composite_set_addComposited
Mar 28, 2026
Merged

[COLLECTIONS_886] [javadoc] CompositeSet.addComposited(Set) does not throw NullPointerException when null is passed#675
garydgregory merged 1 commit intoapache:masterfrom
Partha-SUST16:composite_set_addComposited

Conversation

@Partha-SUST16
Copy link
Copy Markdown
Contributor

The Javadoc for CompositeSet.addComposited(Set) explicitly stated 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 which was reported in COLLECTIONS_886

This PR removed the NPE condition from the method as it already had test code org.apache.commons.collections4.set.CompositeSetTest.testAddComposited which adds null to the CompositeSet using this method.

@Partha-SUST16 Partha-SUST16 changed the title removed NPE condition from CompositeSet.addComposited(Set) as the method can never throw NPE [COLLECTIONS_886] removed NPE condition from CompositeSet.addComposited(Set) as the method can never throw NPE Mar 28, 2026
@garydgregory garydgregory changed the title [COLLECTIONS_886] removed NPE condition from CompositeSet.addComposited(Set) as the method can never throw NPE [COLLECTIONS_886] [javadoc] CompositeSet.addComposited(Set) does not throw NullPointerException when null is passed Mar 28, 2026
@garydgregory garydgregory merged commit 0d89ba2 into apache:master Mar 28, 2026
9 checks passed
@garydgregory
Copy link
Copy Markdown
Member

@Partha-SUST16

Good catch!

Thank you for the pull request :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants