Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0159a7d6 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Prevent UnsupportedOperationException in Completable"

parents ce272b4d 5084305d
Loading
Loading
Loading
Loading
+20 −8
Original line number Original line Diff line number Diff line
@@ -117,7 +117,7 @@ public final class Completable {
        }
        }


        /**
        /**
         * @return {@link true} if {@link #onComplete()} gets called and {@link #mState} is
         * @return {@code true} if {@link #onComplete()} gets called and {@link #mState} is
         *         {@link CompletionState#COMPLETED_WITH_VALUE}.
         *         {@link CompletionState#COMPLETED_WITH_VALUE}.
         */
         */
        @AnyThread
        @AnyThread
@@ -232,13 +232,25 @@ public final class Completable {
        }
        }


        /**
        /**
         * Blocks the calling thread until this object becomes ready to return the value.
         * Blocks the calling thread until this object becomes ready to return the value, even if
         * {@link InterruptedException} is thrown.
         */
         */
        @AnyThread
        @AnyThread
        public void await() {
        public void await() {
            boolean interrupted = false;
            while (true) {
                try {
                try {
                    mLatch.await();
                    mLatch.await();
            } catch (InterruptedException ignored) { }
                    break;
                } catch (InterruptedException ignored) {
                    interrupted = true;
                }
            }

            if (interrupted) {
                // Try to preserve the interrupt bit on this thread.
                Thread.currentThread().interrupt();
            }
        }
        }
    }
    }


@@ -487,7 +499,7 @@ public final class Completable {
    /**
    /**
     * Await the result by the {@link Completable.Values}.
     * Await the result by the {@link Completable.Values}.
     *
     *
     * @return the result once {@link ValueBase#onComplete()}
     * @return the result once {@link ValueBase#onComplete()}.
     */
     */
    @AnyThread
    @AnyThread
    @Nullable
    @Nullable
@@ -499,7 +511,7 @@ public final class Completable {
    /**
    /**
     * Await the int result by the {@link Completable.Int}.
     * Await the int result by the {@link Completable.Int}.
     *
     *
     * @return the result once {@link ValueBase#onComplete()}
     * @return the result once {@link ValueBase#onComplete()}.
     */
     */
    @AnyThread
    @AnyThread
    public static int getIntResult(@NonNull Completable.Int value) {
    public static int getIntResult(@NonNull Completable.Int value) {