RedisBasedLock implements Lock { @Override public Future<Boolean> releaseLock(String lock, String token) { Future<Boolean> future = Future.future(); List<String> keys = Collections.singletonList(buildLockKey(lock)); List<String> arguments = Collections.singletonList(token); ReleaseLockRedisCommand cmd = new ReleaseLockRedisCommand(releaseLockLuaScriptState, keys, arguments, redisClient, log, future); cmd.exec(0); return future; } RedisBasedLock(RedisClient redisClient); @Override Future<Boolean> acquireLock(String lock, String token, long lockExpiryMs); @Override Future<Boolean> releaseLock(String lock, String token); static final String STORAGE_PREFIX; }
@Test public void testReleaseNonExistingLock(TestContext context){ Async async = context.async(); context.assertFalse(jedis.exists(lockKey(lock_1))); redisBasedLock.releaseLock(lock_1, token_1).setHandler(event -> { context.assertTrue(event.succeeded()); context.assertFalse(event.result()); context.assertFalse(jedis.exists(lockKey(lock_1))); async.complete(); }); }