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

Raju Gupta updated LANG-1811:
-----------------------------
    Description: 
h2. Description
The *shuffle()* method in *ArrayUtils* throws a *NullPointerException* when a 
*null* array is passed as input.

This behavior is currently undocumented and inconsistent with other utility 
methods in *ArrayUtils*, which typically tolerate *null* inputs.

*Suggested behavior:*
* Explicitly document that *shuffle()* does not accept *null* arrays, *or*
* Add a null check and safely return without throwing an exception when the 
input array is *null*.

h2. Failing Test Case
{code:java}
@Test
void testShuffleNull() {
    assertDoesNotThrow(() -> ArrayUtils.shuffle((byte[]) null));
}
{code}


  was:
h2. Title
ArrayUtils.shuffle() throws NullPointerException for null array input

h2. Description
The `shuffle()` method in `ArrayUtils` throws a `NullPointerException` when a 
`null` array is passed as input.

This behavior is currently undocumented and inconsistent with other utility 
methods in `ArrayUtils`, which typically tolerate `null` inputs.

*Suggested behavior:*
* Explicitly document that `shuffle()` does not accept `null` arrays, *or*
* Add a null check and safely return without throwing an exception when the 
input array is `null`.

h2. Failing Test Case
{code:java}
@Test
void testShuffleNull() {
    assertDoesNotThrow(() -> ArrayUtils.shuffle((byte[]) null));
}
{code}

h2. Impact
Callers relying on `ArrayUtils` methods to be null-safe may encounter 
unexpected `NullPointerException`s, leading to avoidable runtime failures.


> ArrayUtils.shuffle() throws NullPointerException for null array input
> ---------------------------------------------------------------------
>
>                 Key: LANG-1811
>                 URL: https://issues.apache.org/jira/browse/LANG-1811
>             Project: Commons Lang
>          Issue Type: Bug
>          Components: lang.*
>    Affects Versions: 3.20.0
>            Reporter: Raju Gupta
>            Priority: Minor
>
> h2. Description
> The *shuffle()* method in *ArrayUtils* throws a *NullPointerException* when a 
> *null* array is passed as input.
> This behavior is currently undocumented and inconsistent with other utility 
> methods in *ArrayUtils*, which typically tolerate *null* inputs.
> *Suggested behavior:*
> * Explicitly document that *shuffle()* does not accept *null* arrays, *or*
> * Add a null check and safely return without throwing an exception when the 
> input array is *null*.
> h2. Failing Test Case
> {code:java}
> @Test
> void testShuffleNull() {
>     assertDoesNotThrow(() -> ArrayUtils.shuffle((byte[]) null));
> }
> {code}



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

Reply via email to