From 0d1b90f0151765577e71b19a6d611fc279273d66 Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Thu, 29 Sep 2016 11:23:34 -0400 Subject: [PATCH] Fix `RedisStoreInChAdapIntTests` race condition https://build.spring.io/browse/INT-B41-597 Since Jedis driver is async, we not always receive a reply from the `TX-sync` component immediately. Add loop checking the Redis for the `key` after some `Thread.sleep()` Cherry-picked from https://github.com/spring-projects/spring-integration/commit/f48d01997071d3d9f27af1e1815b7b88c64d9a83 --- ...oreInboundChannelAdapterIntegrationTests.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/spring-integration-redis/src/test/java/org/springframework/integration/redis/inbound/RedisStoreInboundChannelAdapterIntegrationTests.java b/spring-integration-redis/src/test/java/org/springframework/integration/redis/inbound/RedisStoreInboundChannelAdapterIntegrationTests.java index 6844b5de9a..e78775f35d 100644 --- a/spring-integration-redis/src/test/java/org/springframework/integration/redis/inbound/RedisStoreInboundChannelAdapterIntegrationTests.java +++ b/spring-integration-redis/src/test/java/org/springframework/integration/redis/inbound/RedisStoreInboundChannelAdapterIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -94,6 +94,13 @@ public class RedisStoreInboundChannelAdapterIntegrationTests extends RedisAvaila //poll again, should get nothing since the collection was removed during synchronization message = (Message) redisChannel.receive(100); assertNull(message); + + int n = 0; + while (n++ < 100 && template.keys("bar").size() == 0) { + Thread.sleep(100); + } + assertTrue("Rename didn't occur", n < 100); + assertEquals(Long.valueOf(13), template.boundListOps("bar").size()); template.delete("bar"); @@ -161,6 +168,13 @@ public class RedisStoreInboundChannelAdapterIntegrationTests extends RedisAvaila //poll again, should get nothing since the collection was removed during synchronization message = (Message) redisChannel.receive(100); assertNull(message); + + int n = 0; + while (n++ < 100 && template.keys("bar").size() == 0) { + Thread.sleep(100); + } + assertTrue("Rename didn't occur", n < 100); + assertEquals(Long.valueOf(13), template.boundListOps("bar").size()); template.delete("bar");