-
Notifications
You must be signed in to change notification settings - Fork 1.9k
ArrayUtils.shuffle() throws NullPointerException for null array input #1553
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
garydgregory
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rajucomp
Please see my comment.
|
|
||
| @Test | ||
| void testShuffleNull() { | ||
| assertDoesNotThrow(() -> ArrayUtils.shuffle((byte[]) null)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't use assertDoesNotThrow(), as it clutters a one-line method.
You can add to testShuffleByte instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was just one case. The full test case would test for all array types for null input. I have updated the test to cover all the cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@garydgregory Done.
Added a comment. |
b8e186d to
5025a84
Compare
|
Hello @rajucomp |
964b8b4 to
1731046
Compare
|
Hi @garydgregory . Thanks for the fix. I would like some guidance on how to raise PR's for issues and fixes.
I am not sure if I am following the right pattern here. My idea was to first demonstrate the issue and then push the fix for that. This makes it easier for me to track my contributions. Could you please provide some tips here as how to I can better do this and save our times and the back and forth as well? Additionally, it would be better if we provide the chance to review the fix before the changes are merged into the master branch. An additional set of eyes don't hurt and makes the fix error-free. There is a small issue that I found in your fix. I have commited the fix in this PR. Could you review the changes and let me know if all looks good ? Thanks! |
|
Hello @rajucomp I'll get back to this in a little while after updating the Commons Parent POM, which should address the current SPDX failure. What can be confusing is that Jira tickets are reports from anyone and everyone, and that there might not be consensus on a path forward for any given issue. IOW, just because someone created a Jira ticket means that it should be fixed automatically. In general, creating a PR with only a failing test should be the exception, not the rule. If someone reports an issue in Jira or the mailing list, we might ask for a POC in the form of an example, a failing test, something that demonstrates the issue. The usual path is to create a PR that tests and fixes a single issue. The test should fail if the If there is any doubt, you can seek advice in the Jira ticket or on the mailing list. HTH |
Thanks for your contribution to Apache Commons! Your help is appreciated!
Before you push a pull request, review this list:
mvn; that'smvnon the command line by itself.Description
The
shuffle()method inArrayUtilsthrows aNullPointerExceptionwhen anullarray is passed as input.This behavior is currently undocumented and inconsistent with other utility methods in
ArrayUtils, which typically toleratenullinputs.Suggested behavior:
shuffle()does not acceptnullarrays, ornull.Failing Test Case