diff --git a/redisson/src/main/java/org/redisson/api/RFuture.java b/redisson/src/main/java/org/redisson/api/RFuture.java index f555fbc14..6df099828 100644 --- a/redisson/src/main/java/org/redisson/api/RFuture.java +++ b/redisson/src/main/java/org/redisson/api/RFuture.java @@ -29,31 +29,54 @@ import java.util.function.BiConsumer; public interface RFuture extends java.util.concurrent.Future, CompletionStage { /** - * Returns {@code true} if and only if the I/O operation was completed - * successfully. + * Use snippet below instead. + * + *
+     *                 return toCompletableFuture().isDone() && !toCompletableFuture().isCompletedExceptionally();
+     * 
* * @return {@code true} if future was completed successfully */ + @Deprecated boolean isSuccess(); /** - * Returns the cause of the failed I/O operation if the I/O operation has - * failed. + * Use snippet below instead. + * + *
+     *                if (toCompletableFuture().isDone()) {
+     *                    try {
+     *                        toCompletableFuture().getNow(null);
+     *                    } catch (CompletionException e) {
+     *                        return e.getCause();
+     *                    } catch (CancellationException e) {
+     *                        return e;
+     *                    }
+     *                }
+     *                return null;
+     * 
* * @return the cause of the failure. * {@code null} if succeeded or this future is not * completed yet. */ + @Deprecated Throwable cause(); - + /** - * Return the result without blocking. If the future is not done yet this will return {@code null}. + * Use snippet below instead. + * + *
+     *                 try {
+     *                     return toCompletableFuture().getNow(null);
+     *                 } catch (Exception e) {
+     *                     return null;
+     *                 }
+     * 
* - * As it is possible that a {@code null} value is used to mark the future as successful you also need to check - * if the future is really done with {@link #isDone()} and not relay on the returned {@code null} value. - * * @return object */ + @Deprecated V getNow(); /** diff --git a/redisson/src/test/java/org/redisson/RedissonSpinLockTest.java b/redisson/src/test/java/org/redisson/RedissonSpinLockTest.java index 7447655df..36e0800f7 100644 --- a/redisson/src/test/java/org/redisson/RedissonSpinLockTest.java +++ b/redisson/src/test/java/org/redisson/RedissonSpinLockTest.java @@ -432,7 +432,7 @@ public class RedissonSpinLockTest extends BaseConcurrentTest { AtomicBoolean lockAsyncSucceed = new AtomicBoolean(); Thread thread = new Thread(() -> { RFuture booleanRFuture = lock.lockAsync(); - booleanRFuture.onComplete((res, e) -> { + booleanRFuture.whenComplete((res, e) -> { if (e != null) { Assertions.fail("Lock aquire failed for some reason"); } @@ -456,7 +456,7 @@ public class RedissonSpinLockTest extends BaseConcurrentTest { AtomicBoolean lockAsyncSucceed = new AtomicBoolean(); Thread thread = new Thread(() -> { RFuture booleanRFuture = lock.tryLockAsync(1, 30, TimeUnit.SECONDS); - booleanRFuture.onComplete((res, e) -> { + booleanRFuture.whenComplete((res, e) -> { if (e != null) { Assertions.fail("Lock aquire failed for some reason"); } @@ -481,7 +481,7 @@ public class RedissonSpinLockTest extends BaseConcurrentTest { AtomicBoolean lockAsyncSucceed = new AtomicBoolean(); Thread thread = new Thread(() -> { RFuture booleanRFuture = lock.tryLockAsync(); - booleanRFuture.onComplete((res, e) -> { + booleanRFuture.whenComplete((res, e) -> { if (e != null) { Assertions.fail("Lock aquire failed for some reason"); }