Skip to content

Commit

Permalink
INT-3576: Fix NPE in the RedisAvailableTests
Browse files Browse the repository at this point in the history
  • Loading branch information
artembilan authored and garyrussell committed Dec 10, 2014
1 parent 3d43ad1 commit 8ec4ab0
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.springframework.integration.redis.rules;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import org.junit.Rule;
Expand Down Expand Up @@ -50,10 +52,17 @@ protected RedisConnectionFactory getConnectionFactoryForTest() {
}

protected void awaitContainerSubscribed(RedisMessageListenerContainer container) throws Exception {
RedisConnection connection = TestUtils.getPropertyValue(container, "subscriptionTask.connection",
RedisConnection.class);
RedisConnection connection = null;

int n = 0;
while (n++ < 100 &&
(connection =
TestUtils.getPropertyValue(container, "subscriptionTask.connection", RedisConnection .class)) == null) {
Thread.sleep(100);
}
assertNotNull("RedisMessageListenerContainer Failed to Connect", connection);

n = 0;
while (n++ < 100 && !connection.isSubscribed()) {
Thread.sleep(100);
}
Expand Down

0 comments on commit 8ec4ab0

Please sign in to comment.