From c6ecd4603ddecedb3a882e96464960d0ef8530d2 Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Tue, 24 Jul 2018 16:25:44 +0200 Subject: [PATCH] DATAREDIS-843 - Polishing. Improve test stability to not concurrently create atomic counter instances. --- .../support/atomic/RedisAtomicIntegerTests.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/test/java/org/springframework/data/redis/support/atomic/RedisAtomicIntegerTests.java b/src/test/java/org/springframework/data/redis/support/atomic/RedisAtomicIntegerTests.java index 74f1c1539..35d10c7fb 100644 --- a/src/test/java/org/springframework/data/redis/support/atomic/RedisAtomicIntegerTests.java +++ b/src/test/java/org/springframework/data/redis/support/atomic/RedisAtomicIntegerTests.java @@ -149,18 +149,17 @@ public class RedisAtomicIntegerTests extends AbstractRedisAtomicsTests { @Test // DATAREDIS-108, DATAREDIS-843 public void testCompareSet() throws Exception { - final AtomicBoolean alreadySet = new AtomicBoolean(false); - final int NUM = 50; - final String KEY = getClass().getSimpleName() + ":atomic:counter"; - final CountDownLatch latch = new CountDownLatch(NUM); - - final AtomicBoolean failed = new AtomicBoolean(false); + AtomicBoolean alreadySet = new AtomicBoolean(false); + int NUM = 50; + String KEY = getClass().getSimpleName() + ":atomic:counter"; + CountDownLatch latch = new CountDownLatch(NUM); + AtomicBoolean failed = new AtomicBoolean(false); + RedisAtomicInteger atomicInteger = new RedisAtomicInteger(KEY, factory); for (int i = 0; i < NUM; i++) { new Thread(() -> { - RedisAtomicInteger atomicInteger = new RedisAtomicInteger(KEY, factory); try { if (atomicInteger.compareAndSet(0, 1)) { if (alreadySet.get()) {