Skip to content

Commit f544d1a

Browse files
committed
jedis npe check
1 parent c2b4d8a commit f544d1a

File tree

1 file changed

+9
-7
lines changed
  • redis5/redis5-side/redis-all-side/src/main/java/com/dtstack/flink/sql/side/redis

1 file changed

+9
-7
lines changed

redis5/redis5-side/redis-all-side/src/main/java/com/dtstack/flink/sql/side/redis/RedisAllReqRow.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ protected void reloadCache() {
103103
loadData(newCache);
104104
} catch (SQLException e) {
105105
LOG.error("", e);
106+
throw new RuntimeException(e);
106107
}
107108

108109
cacheRef.set(newCache);
@@ -160,21 +161,22 @@ private void loadData(Map<String, Map<String, String>> tmpCache) throws SQLExcep
160161
JedisCommands jedis = null;
161162
try {
162163
StringBuilder keyPattern = new StringBuilder(tableInfo.getTableName());
163-
for(String key : tableInfo.getPrimaryKeys()){
164+
for (String key : tableInfo.getPrimaryKeys()) {
164165
keyPattern.append("_").append("*");
165-
};
166+
}
166167
jedis = getJedisWithRetry(CONN_RETRY_NUM);
168+
if (null == jedis) {
169+
throw new RuntimeException("redis all load data error,get jedis commands error!");
170+
}
167171
Set<String> keys = getRedisKeys(RedisType.parse(tableInfo.getRedisType()), jedis, keyPattern.toString());
168-
if(CollectionUtils.isEmpty(keys)){
172+
if (CollectionUtils.isEmpty(keys)) {
169173
return;
170174
}
171-
for(String key : keys){
175+
for (String key : keys) {
172176
tmpCache.put(key, jedis.hgetAll(key));
173177
}
174-
} catch (Exception e){
175-
LOG.error("", e);
176178
} finally {
177-
if (jedis != null){
179+
if (jedis != null) {
178180
try {
179181
((Closeable) jedis).close();
180182
} catch (IOException e) {

0 commit comments

Comments
 (0)