Skip to content

Commit 74a5652

Browse files
committed
DATAREDIS-505 - Polishing.
Extend date range in license header. Retrieve connection and config for possible reconfiguration only if keyspaceNotificationsConfigParameter has a value. Original pull request: #202.
1 parent 65c7b2c commit 74a5652

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/main/java/org/springframework/data/redis/listener/KeyspaceEventMessageListener.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015 the original author or authors.
2+
* Copyright 2015-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -75,17 +75,22 @@ public void onMessage(Message message, byte[] pattern) {
7575
*/
7676
public void init() {
7777

78-
RedisConnection connection = listenerContainer.getConnectionFactory().getConnection();
79-
List<String> config = connection.getConfig("notify-keyspace-events");
80-
8178
if (StringUtils.hasText(keyspaceNotificationsConfigParameter)) {
82-
if (config.size() == 2) {
83-
if (!StringUtils.hasText(config.get(1))) {
79+
80+
RedisConnection connection = listenerContainer.getConnectionFactory().getConnection();
81+
82+
try {
83+
84+
List<String> config = connection.getConfig("notify-keyspace-events");
85+
86+
if (config.size() == 2 && !StringUtils.hasText(config.get(1))) {
8487
connection.setConfig("notify-keyspace-events", keyspaceNotificationsConfigParameter);
8588
}
89+
90+
} finally {
91+
connection.close();
8692
}
8793
}
88-
connection.close();
8994

9095
doRegister(listenerContainer);
9196
}

0 commit comments

Comments
 (0)