Skip to content

Commit 659613c

Browse files
artembilangaryrussell
authored andcommitted
Fix RedisUtils.isUnlinkAvailable() for NPE
Fixes #2868 * Check if `redis_version` property is returned from the `info` before parsing **Cherry-pick to 5.1.x**
1 parent 6f3fd09 commit 659613c

File tree

1 file changed

+9
-2
lines changed
  • spring-integration-redis/src/main/java/org/springframework/integration/redis/util

1 file changed

+9
-2
lines changed

spring-integration-redis/src/main/java/org/springframework/integration/redis/util/RedisUtils.java

+9-2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
import org.springframework.data.redis.core.RedisCallback;
2525
import org.springframework.data.redis.core.RedisOperations;
26+
import org.springframework.util.StringUtils;
2627

2728
/**
2829
* A set of utility methods for common Redis functions.
@@ -61,8 +62,14 @@ public static boolean isUnlinkAvailable(RedisOperations<?, ?> redisOperations) {
6162
Properties info = redisOperations.execute(
6263
(RedisCallback<Properties>) connection -> connection.serverCommands().info(SECTION));
6364
if (info != null) {
64-
int majorVersion = Integer.parseInt(info.getProperty(VERSION_PROPERTY).split("\\.")[0]);
65-
return majorVersion >= 4;
65+
String version = info.getProperty(VERSION_PROPERTY);
66+
if (StringUtils.hasText(version)) {
67+
int majorVersion = Integer.parseInt(version.split("\\.")[0]);
68+
return majorVersion >= 4;
69+
}
70+
else {
71+
return false;
72+
}
6673
}
6774
else {
6875
throw new IllegalStateException("The INFO command cannot be used in pipeline/transaction.");

0 commit comments

Comments
 (0)