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

Commit c49fc496 authored by Steven Moreland's avatar Steven Moreland Committed by Android (Google) Code Review
Browse files

Merge "Parcel: harder recycling errors" into main

parents 6663bc11 025513f3
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -593,11 +593,11 @@ public final class Parcel {
     */
    public final void recycle() {
        if (mRecycled) {
            Log.wtf(TAG, "Recycle called on unowned Parcel. (recycle twice?) Here: "
            String error = "Recycle called on unowned Parcel. (recycle twice?) Here: "
                    + Log.getStackTraceString(new Throwable())
                    + " Original recycle call (if DEBUG_RECYCLE): ", mStack);

            return;
                    + " Original recycle call (if DEBUG_RECYCLE): ";
            Log.wtf(TAG, error, mStack);
            throw new IllegalStateException(error, mStack);
        }
        mRecycled = true;

+5 −1
Original line number Diff line number Diff line
@@ -361,7 +361,11 @@ public class ParcelTest {

        p.setClassCookie(ParcelTest.class, "to_be_discarded_cookie");
        p.recycle();
        assertThat(p.getClassCookie(ParcelTest.class)).isNull();

        // cannot access Parcel after it's recycled!
        // this test is equivalent to checking hasClassCookie false
        // after obtaining above
        // assertThat(p.getClassCookie(ParcelTest.class)).isNull();
    }

    @Test