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

Commit af04dd2a authored by Hai Zhang's avatar Hai Zhang Committed by Android (Google) Code Review
Browse files

Merge "Only construct real Throwable objects in AndroidFuture.readThrowable()." into sc-dev

parents f408df63 2d6a545e
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.os.Looper;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.RemoteException;
import android.util.EventLog;
import android.util.Log;

import com.android.internal.annotations.GuardedBy;
@@ -601,9 +602,14 @@ public class AndroidFuture<T> extends CompletableFuture<T> implements Parcelable
        String messageWithStackTrace = message + '\n' + stackTrace;
        Throwable throwable;
        try {
            Class<?> clazz = Class.forName(className);
            Class<?> clazz = Class.forName(className, true, Parcelable.class.getClassLoader());
            if (Throwable.class.isAssignableFrom(clazz)) {
                Constructor<?> constructor = clazz.getConstructor(String.class);
                throwable = (Throwable) constructor.newInstance(messageWithStackTrace);
            } else {
                android.util.EventLog.writeEvent(0x534e4554, "186530450", -1, "");
                throwable = new RuntimeException(className + ": " + messageWithStackTrace);
            }
        } catch (Throwable t) {
            throwable = new RuntimeException(className + ": " + messageWithStackTrace);
            throwable.addSuppressed(t);