-
Notifications
You must be signed in to change notification settings - Fork 638
Description
Context: https://issuetracker.google.com/393513316
ArrayMap is a performance-sensitive collection which does not support holding references to the returned Map.Entry when iterating through it. Many kotlin-stdlib extensions on collections do not create defensive copies (intentionally for performance), so it is quite confusing to end users that for example RemoteMessage.data.entries.sortedBy { ..}
returned a list of the last entry repeated size
times.
Instead, I would generally recommend that public API return defensive copies of collections to avoid this confusion and to keep the performance sensitive stuff internal. We have a similar rule for android platform + libraries here: go/android-api-guidelines#type-semantics
I believe this is the problematic call-site:
firebase-android-sdk/firebase-messaging/src/main/java/com/google/firebase/messaging/Constants.java
Line 120 in 5e778b9
public static ArrayMap<String, String> extractDeveloperDefinedPayload(Bundle bundle) { |
and the affected api in the linked buganizer issue against androidx.collection:
Line 130 in 5e778b9
public Map<String, String> getData() { |