Skip to content

Commit d40a2d6

Browse files
committed
Removes messageQueue since produces memory leaks
1 parent 9376f30 commit d40a2d6

File tree

2 files changed

+0
-35
lines changed

2 files changed

+0
-35
lines changed

android-core/src/main/java/com/mparticle/internal/BaseHandler.java

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@
1313
public class BaseHandler extends Handler {
1414
private volatile boolean disabled;
1515
private volatile boolean handling;
16-
private ConcurrentHashMap<Message, Boolean> messageQueue = new ConcurrentHashMap();
17-
18-
public Set<Message> getMessageQueue() {
19-
return messageQueue.keySet();
20-
}
2116

2217
public BaseHandler() {
2318
}
@@ -50,9 +45,6 @@ public final void handleMessage(Message msg) {
5045
}
5146
handling = true;
5247
try {
53-
if (msg != null) {
54-
messageQueue.remove(msg);
55-
}
5648
if (msg != null && msg.what == -1 && msg.obj instanceof CountDownLatch) {
5749
((CountDownLatch) msg.obj).countDown();
5850
} else {
@@ -78,22 +70,9 @@ public boolean sendMessageAtTime(Message msg, long uptimeMillis) {
7870
if (InternalListenerManager.isEnabled()) {
7971
InternalListenerManager.getListener().onThreadMessage(getClass().getName(), msg, false);
8072
}
81-
if (msg != null) {
82-
messageQueue.put(msg, true);
83-
}
8473
return super.sendMessageAtTime(msg, uptimeMillis);
8574
}
8675

87-
public void removeMessage(int what) {
88-
Set<Message> messages = messageQueue.keySet();
89-
for (Message message : messages) {
90-
if (message.what == what) {
91-
messageQueue.remove(message);
92-
}
93-
}
94-
super.removeMessages(what);
95-
}
96-
9776
//Override this in order to handle messages
9877
public void handleMessageImpl(Message msg) {
9978
}

testutils/src/main/java/com/mparticle/AccessUtils.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,6 @@ public static void reset(Context context, boolean deleteDatabase, boolean switch
1919
MParticle.reset(context, deleteDatabase, switchingWorkspaces);
2020
}
2121

22-
/**
23-
* This is a way less than ideal implementation, but I think the insight is very important.
24-
*
25-
* This method returns an ordered list of the pending Messages in the UploadHandler queue. This
26-
* gives us the ability to test the UploadHandler's true "state" when looking closely at how
27-
* our Upload loop is performing
28-
*
29-
* @return
30-
*/
31-
@RequiresApi(api = Build.VERSION_CODES.M)
32-
public static Set<Message> getUploadHandlerMessageQueue() {
33-
return getMessageManager().mUploadHandler.getMessageQueue();
34-
}
35-
3622
public static MessageManager getMessageManager() {
3723
return MParticle.getInstance().mMessageManager;
3824
}

0 commit comments

Comments
 (0)