Skip to content
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

Deprecate StringUtils.isEmpty(Object) and replace remaining usage (e.g. with ObjectUtils.isEmpty) #25945

Closed
sabi0 opened this issue Oct 21, 2020 · 0 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Milestone

Comments

@sabi0
Copy link

sabi0 commented Oct 21, 2020

With static imports code like this looks perfectly fine:

        List<String> data = ...

        if (isEmpty(data)) {

But if the import has StringUtils.isEmpty the condition above will not work correctly for empty List introducing a hidden, difficult to spot bug.

If you are really keen on keeping this method it would be better to rename it to isEmptyString to at least make the error more obvious. (I believe this name also matches the method intention better than generic isEmpty.)

But with the #17710 in place I do not think StringUtils.isEmpty(Object) is still needed. And should probably be deprecated and eventually removed.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Oct 21, 2020
@sbrannen sbrannen added the in: core Issues in core modules (aop, beans, core, context, expression) label Oct 21, 2020
@jhoeller jhoeller self-assigned this Oct 21, 2020
@jhoeller jhoeller added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Oct 21, 2020
@jhoeller jhoeller added this to the 5.3 GA milestone Oct 21, 2020
@jhoeller jhoeller changed the title StringUtils.isEmpty(Object) could result in hidden bugs Deprecate StringUtils.isEmpty(Object) and replace remaining usage (e.g. with ObjectUtils.isEmpty) Oct 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

4 participants