Fixed - FairLock methods throw 'attempt to compare nil with number' error #4153

pull/5884/head
Nikita Koksharov 10 months ago
parent 4a849af9b3
commit 703f6f57bf

@ -116,8 +116,8 @@ public class RedissonFairLock extends RedissonLock implements RLock {
"if firstThreadId2 == false then " +
"break;" +
"end;" +
"local timeout = tonumber(redis.call('zscore', KEYS[3], firstThreadId2));" +
"if timeout <= tonumber(ARGV[3]) then " +
"local timeout = redis.call('zscore', KEYS[3], firstThreadId2);" +
"if timeout ~= false and tonumber(timeout) <= tonumber(ARGV[3]) then " +
// remove the item from the queue and timeout set
// NOTE we do not alter any other timeout
"redis.call('zrem', KEYS[3], firstThreadId2);" +
@ -162,8 +162,8 @@ public class RedissonFairLock extends RedissonLock implements RLock {
"break;" +
"end;" +
"local timeout = tonumber(redis.call('zscore', KEYS[3], firstThreadId2));" +
"if timeout <= tonumber(ARGV[4]) then " +
"local timeout = redis.call('zscore', KEYS[3], firstThreadId2);" +
"if timeout ~= false and tonumber(timeout) <= tonumber(ARGV[4]) then " +
// remove the item from the queue and timeout set
// NOTE we do not alter any other timeout
"redis.call('zrem', KEYS[3], firstThreadId2);" +
@ -247,8 +247,8 @@ public class RedissonFairLock extends RedissonLock implements RLock {
+ "if firstThreadId2 == false then "
+ "break;"
+ "end; "
+ "local timeout = tonumber(redis.call('zscore', KEYS[3], firstThreadId2));"
+ "if timeout <= tonumber(ARGV[4]) then "
+ "local timeout = redis.call('zscore', KEYS[3], firstThreadId2);"
+ "if timeout ~= false and tonumber(timeout) <= tonumber(ARGV[4]) then "
+ "redis.call('zrem', KEYS[3], firstThreadId2); "
+ "redis.call('lpop', KEYS[2]); "
+ "else "
@ -328,8 +328,8 @@ public class RedissonFairLock extends RedissonLock implements RLock {
+ "if firstThreadId2 == false then "
+ "break;"
+ "end; "
+ "local timeout = tonumber(redis.call('zscore', KEYS[3], firstThreadId2));"
+ "if timeout <= tonumber(ARGV[2]) then "
+ "local timeout = redis.call('zscore', KEYS[3], firstThreadId2);"
+ "if timeout ~= false and tonumber(timeout) <= tonumber(ARGV[2]) then "
+ "redis.call('zrem', KEYS[3], firstThreadId2); "
+ "redis.call('lpop', KEYS[2]); "
+ "else "

@ -924,20 +924,29 @@ public class CommandAsyncService implements CommandAsyncExecutor {
public <T> CompletionStage<T> handleNoSync(CompletionStage<T> stage, Supplier<CompletionStage<?>> supplier) {
CompletionStage<T> s = stage.handle((r, ex) -> {
if (ex != null) {
if (ex.getCause().getMessage() != null
&& ex.getCause().getMessage().equals("None of slaves were synced")) {
if (ex.getCause() != null
&& ex.getCause().getMessage() != null
&& ex.getCause().getMessage().equals("None of slaves were synced")) {
return supplier.get().handle((r1, e) -> {
if (e != null) {
if (ex.getCause().getMessage() != null
&& e.getCause().getMessage().equals("None of slaves were synced")) {
if (e.getCause() != null
&& e.getCause().getMessage() != null
&& e.getCause().getMessage().equals("None of slaves were synced")) {
throw new CompletionException(ex.getCause());
}
e.getCause().addSuppressed(ex.getCause());
if (e.getCause() != null) {
e.getCause().addSuppressed(ex.getCause());
} else {
e.addSuppressed(ex.getCause());
}
}
throw new CompletionException(ex.getCause());
});
} else {
throw new CompletionException(ex.getCause());
if (ex.getCause() != null) {
throw new CompletionException(ex.getCause());
}
throw new CompletionException(ex);
}
}
return CompletableFuture.completedFuture(r);

Loading…
Cancel
Save