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

[Spring 5.3.0] StringUtils#isEmpty has bean deprecated #1015

Closed
btkatoufm opened this issue Nov 2, 2020 · 2 comments
Closed

[Spring 5.3.0] StringUtils#isEmpty has bean deprecated #1015

btkatoufm opened this issue Nov 2, 2020 · 2 comments

Comments

@btkatoufm
Copy link
Contributor

Description

Part of #989

Starting with Spring 5.3.0, StringUtils#isEmpty has been deprecated.

Possible Solution

Replace.
from org.springframework.util.StringUtils#isEmpty
to org.springframework.util.ObjectUtils#ObjectUtils.isEmpty

Affect versions

  • 5.7.0.RELEASE

Issue links

Links to related issues.

@yoshikawaa
Copy link
Contributor

https://github.com/spring-projects/spring-framework/blob/5acffaa72da10ba42fe547eeea44d8615cbf99b9/spring-core/src/main/java/org/springframework/util/StringUtils.java#L94-L98

	 * @deprecated as of 5.3, in favor of {@link #hasLength(String)} and
	 * {@link #hasText(String)} (or {@link ObjectUtils#isEmpty(Object)})

You may better to change to !StringUtils#hasLength or !StringUtils#hasText instead of ObjectUtils#isEmpty.
If you use isEmpty without careful consideration, you may not notice the difference between an empty String and an empty String array, for example.

@btkatoufm
Copy link
Contributor Author

If you use isEmpty without careful consideration, you may not notice the difference between an empty String and an empty String array, for example.

I agree with you.
We want to make sure it's an empty string, so we'll use !StringUtils#hasLength or !StringUtils#hasText.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants