Parcel: noop upon double recycle

Fix this scenario:

  Parcel p = Parcel.obtain();
  p.recycle();
  p.recycle(); // illegal but possible

  Parcel p1 = Parcel.obtain();
  Parcel p2 = Parcel.obtain();

  ASSERT_TRUE(p1 != p2); // fail!

Signed-off-by: Jintao Zhu <zhu.jintao@gm.com>

Change-Id: Ied25188549801122874a05c2e66969e1f281b346
This commit is contained in:
Jintao Zhu
2022-10-21 20:19:29 +08:00
committed by Jintao Zhu
parent 90a441ea64
commit 64ff38669a

View File

@@ -560,9 +560,11 @@ public final class Parcel {
*/
public final void recycle() {
if (mRecycled) {
Log.w(TAG, "Recycle called on unowned Parcel. (recycle twice?) Here: "
Log.wtf(TAG, "Recycle called on unowned Parcel. (recycle twice?) Here: "
+ Log.getStackTraceString(new Throwable())
+ " Original recycle call (if DEBUG_RECYCLE): ", mStack);
return;
}
mRecycled = true;