Skip to content

Fix RedisUtils.isUnlinkAvailable() for NPE #2870

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

Merged
merged 1 commit into from
Mar 29, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import org.springframework.data.redis.core.RedisCallback;
import org.springframework.data.redis.core.RedisOperations;
import org.springframework.util.StringUtils;

/**
* A set of utility methods for common Redis functions.
Expand Down Expand Up @@ -61,8 +62,14 @@ public static boolean isUnlinkAvailable(RedisOperations<?, ?> redisOperations) {
Properties info = redisOperations.execute(
(RedisCallback<Properties>) connection -> connection.serverCommands().info(SECTION));
if (info != null) {
int majorVersion = Integer.parseInt(info.getProperty(VERSION_PROPERTY).split("\\.")[0]);
return majorVersion >= 4;
String version = info.getProperty(VERSION_PROPERTY);
if (StringUtils.hasText(version)) {
int majorVersion = Integer.parseInt(version.split("\\.")[0]);
return majorVersion >= 4;
}
else {
return false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should fall back to a spring.integration.properties?

Clearly, their version supports the operation.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh? What is the difference between spring.integration.properties or redis_version property?
Technically they are the same, only the problem that you abusing a system renaming such an important property.
I mean the same way you definitely can change the property in the spring.integration.properties file and also may break the system

Our goal here is to use faster delete on Redis, if it is not available by some reason we fall back to the regular blocking delete.
So, if you rename redis_version, you just make your own life harder 😄

That's why I'd stay with the false as a fallback.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK; makes sense; thanks.

}
}
else {
throw new IllegalStateException("The INFO command cannot be used in pipeline/transaction.");
Expand Down