Skip to content

StringUtils.equals returns false if both arguments are null #6603

@BailinGao

Description

@BailinGao

Describe the bug

StringUtils.equals' javadoc says that passing in two nulls will return true, but the code will always return false because it does a short circuit check for if one of them is null.

Changing it to return true would match the behavior of other StringUtils implementation, such as Apache Commons.

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

StringUtils.equals(null, null) == true

Current Behavior

StringUtils.equals(null, null) == false

Reproduction Steps

assertTrue(StringUtils.equals(null, null));

Possible Solution

Change the code to check if both arguments are null

Additional Information/Context

This bug has been around for a long time, including SDK v1

AWS Java SDK version used

2.39.6

JDK version used

8

Operating System and version

Windows 11

Metadata

Metadata

Assignees

Labels

bugThis issue is a bug.needs-reviewThis issue or PR needs review from the team.p3This is a minor priority issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions