From fc9ff4c834c5b3a3c4b024b89375d6c329092791 Mon Sep 17 00:00:00 2001 From: Jeff Brown Date: Fri, 10 Jun 2011 17:56:08 -0700 Subject: Always clear the Message when recycled. Clear the Message when it is recycled, even if it will not go back into the Message pool. This makes the behavior of recycle() more consistent and ensures that the Message does not hold onto other object after it has been recycled (useful in case there are stale references to the Message lingering elsewhere). Change-Id: I26b6a4b629f9c0b6bed70fdc42734919f30e64c4 --- core/java/android/os/Message.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'core/java/android/os') diff --git a/core/java/android/os/Message.java b/core/java/android/os/Message.java index 557e53f..844ed6a 100644 --- a/core/java/android/os/Message.java +++ b/core/java/android/os/Message.java @@ -249,9 +249,10 @@ public final class Message implements Parcelable { * freed. */ public void recycle() { + clearForRecycle(); + synchronized (sPoolSync) { if (sPoolSize < MAX_POOL_SIZE) { - clearForRecycle(); next = sPool; sPool = this; sPoolSize++; -- cgit v1.1