diff --git a/redisson/src/main/java/org/redisson/RedissonSortedSet.java b/redisson/src/main/java/org/redisson/RedissonSortedSet.java index 70d40922b..3fabd7372 100644 --- a/redisson/src/main/java/org/redisson/RedissonSortedSet.java +++ b/redisson/src/main/java/org/redisson/RedissonSortedSet.java @@ -224,37 +224,15 @@ public class RedissonSortedSet extends RedissonExpirable implements RSortedSe } @Override - public RFuture addAsync(final V value) { - CompletableFuture promise = new CompletableFuture<>(); - commandExecutor.getServiceManager().getExecutor().execute(new Runnable() { - public void run() { - try { - boolean res = add(value); - promise.complete(res); - } catch (Exception e) { - promise.completeExceptionally(e); - } - } - }); - return new CompletableFutureWrapper<>(promise); + public RFuture addAsync(V value) { + CompletableFuture f = CompletableFuture.supplyAsync(() -> add(value), getServiceManager().getExecutor()); + return new CompletableFutureWrapper<>(f); } @Override - public RFuture removeAsync(final Object value) { - CompletableFuture promise = new CompletableFuture<>(); - commandExecutor.getServiceManager().getExecutor().execute(new Runnable() { - @Override - public void run() { - try { - boolean result = remove(value); - promise.complete(result); - } catch (Exception e) { - promise.completeExceptionally(e); - } - } - }); - - return new CompletableFutureWrapper<>(promise); + public RFuture removeAsync(Object value) { + CompletableFuture f = CompletableFuture.supplyAsync(() -> remove(value), getServiceManager().getExecutor()); + return new CompletableFutureWrapper<>(f); } @Override