You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Partha Paul (Jira)" <ji...@apache.org> on 2026/03/27 02:28:00 UTC

[jira] [Created] (LANG-1820) ObjectUtils.anyNull(Object) returns false for empty array, which contradicts Javadoc which states true should be returned

Partha Paul created LANG-1820:
---------------------------------

             Summary: ObjectUtils.anyNull(Object) returns false for empty array, which contradicts Javadoc which states true should be returned
                 Key: LANG-1820
                 URL: https://issues.apache.org/jira/browse/LANG-1820
             Project: Commons Lang
          Issue Type: Bug
    Affects Versions: 3.20.0
            Reporter: Partha Paul


The Javadoc for {{ObjectUtils.anyNull(Object...)}} {{@param}} states that {{true}} should be returned when the array is null or empty. However, the current implementation delegates to {{{}!allNotNull(values){}}}, and {{allNotNull()}} returns {{true}} for empty arrays, causing {{anyNull()}} to return {{false}} for empty arrays. This directly contradicts its own documented contract.

The two methods have conflicting contracts for the empty array case currently:

{{allNotNull()}} Javadoc states: {{@returns true}} if all values in the array are not null or array contains no elements
{{anyNull()}} Javadoc states: {{@returns true}} if the array is null or empty

Since {{anyNull()}} is implemented as {{{}!allNotNull(){}}}, it cannot satisfy both contracts simultaneously for the empty array case.

h5. Steps to Reproduce
{code:java}
@Test
void testAnyNull_EmptyArray_ReturnsTrue() {
    assertTrue(ObjectUtils.anyNull(), "anyNull should return true for an empty array per Javadoc");
    assertTrue(ObjectUtils.anyNull(new Object[] {}), "anyNull should return true for an empty array per Javadoc");
}
{code}
Both assertions will fail because {{anyNull()}} returns {{false}} for empty arrays.



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