diff --git a/spring-integration-redis/src/main/java/org/springframework/integration/redis/util/RedisLockRegistry.java b/spring-integration-redis/src/main/java/org/springframework/integration/redis/util/RedisLockRegistry.java index 43a0cbc177..c2a23405fc 100644 --- a/spring-integration-redis/src/main/java/org/springframework/integration/redis/util/RedisLockRegistry.java +++ b/spring-integration-redis/src/main/java/org/springframework/integration/redis/util/RedisLockRegistry.java @@ -136,6 +136,7 @@ public final class RedisLockRegistry implements LockRegistry { * @param registryKey The key prefix for locks. * @param expireAfter The expiration in milliseconds. */ + @SuppressWarnings("deprecation") public RedisLockRegistry(RedisConnectionFactory connectionFactory, String registryKey, long expireAfter) { this(connectionFactory, registryKey, expireAfter, new DefaultLockRegistry()); } @@ -147,7 +148,9 @@ public final class RedisLockRegistry implements LockRegistry { * @param expireAfter The expiration in milliseconds. * @param localRegistry The local registry used to reduce wait time, * {@link DefaultLockRegistry} is used by default. + * @deprecated since 4.3.10, will be removed in 5.0, - the {@code localRegistry} isn't used any more */ + @Deprecated public RedisLockRegistry(RedisConnectionFactory connectionFactory, String registryKey, long expireAfter, LockRegistry localRegistry) { Assert.notNull(connectionFactory, "'connectionFactory' cannot be null"); @@ -172,7 +175,9 @@ public final class RedisLockRegistry implements LockRegistry { * different {@link RedisLock} objects for same unlocked key. * @param useWeakReferences set to true for switch thread local weak references storage on, false by default * @since 4.0.7 + * @deprecated since 4.3.10, will be removed in 5.0, - the thread local cache isn't used any more */ + @Deprecated public void setUseWeakReferences(boolean useWeakReferences) { this.useWeakReferences = useWeakReferences; } @@ -292,6 +297,12 @@ public final class RedisLockRegistry implements LockRegistry { return lock; } + /** + * A list of locks in store for this {@link #registryKey}. + * @return the list of locks in store for this {@link #registryKey} + * @deprecated since 4.3.10, will be removed in 5.0 to avoid deserialized locks created in different process + */ + @Deprecated public Collection listLocks() { return this.redisTemplate.execute(new RedisCallback>() { diff --git a/spring-integration-redis/src/test/java/org/springframework/integration/redis/util/RedisLockRegistryTests.java b/spring-integration-redis/src/test/java/org/springframework/integration/redis/util/RedisLockRegistryTests.java index 365a2ab150..9f751ce93c 100644 --- a/spring-integration-redis/src/test/java/org/springframework/integration/redis/util/RedisLockRegistryTests.java +++ b/spring-integration-redis/src/test/java/org/springframework/integration/redis/util/RedisLockRegistryTests.java @@ -352,24 +352,6 @@ public class RedisLockRegistryTests extends RedisAvailableTests { assertNull(TestUtils.getPropertyValue(registry, "hardThreadLocks", ThreadLocal.class).get()); } - @Test - @RedisAvailable - public void testList() throws Exception { - RedisLockRegistry registry = new RedisLockRegistry(this.getConnectionFactoryForTest(), this.registryKey); - Lock foo = registry.obtain("foo"); - foo.lockInterruptibly(); - Lock bar = registry.obtain("bar"); - bar.lockInterruptibly(); - Lock baz = registry.obtain("baz"); - baz.lockInterruptibly(); - Collection locks = registry.listLocks(); - assertEquals(3, locks.size()); - foo.unlock(); - bar.unlock(); - baz.unlock(); - assertNull(TestUtils.getPropertyValue(registry, "hardThreadLocks", ThreadLocal.class).get()); - } - @Test @RedisAvailable public void testExpireNoLockInStore() throws Exception { @@ -391,7 +373,6 @@ public class RedisLockRegistryTests extends RedisAvailableTests { @RedisAvailable public void testExpireDuringSecondObtain() throws Exception { RedisLockRegistry registry = new RedisLockRegistry(this.getConnectionFactoryForTest(), this.registryKey, 100); - registry.setUseWeakReferences(true); Lock foo = registry.obtain("foo"); foo.lockInterruptibly(); waitForExpire("foo"); @@ -433,13 +414,12 @@ public class RedisLockRegistryTests extends RedisAvailableTests { public void testEquals() throws Exception { RedisConnectionFactory connectionFactory = this.getConnectionFactoryForTest(); RedisLockRegistry registry1 = new RedisLockRegistry(connectionFactory, this.registryKey); - registry1.setUseWeakReferences(true); RedisLockRegistry registry2 = new RedisLockRegistry(connectionFactory, this.registryKey); RedisLockRegistry registry3 = new RedisLockRegistry(connectionFactory, this.registryKey2); Lock lock1 = registry1.obtain("foo"); + lock1.lock(); Lock lock2 = registry1.obtain("foo"); assertEquals(lock1, lock2); - lock1.lock(); lock2.lock(); assertEquals(lock1, lock2); lock1.unlock(); @@ -466,7 +446,6 @@ public class RedisLockRegistryTests extends RedisAvailableTests { @RedisAvailable public void testThreadLocalListLeaks() { RedisLockRegistry registry = new RedisLockRegistry(this.getConnectionFactoryForTest(), this.registryKey, 100); - registry.setUseWeakReferences(true); for (int i = 0; i < 10; i++) { registry.obtain("foo" + i);