Files
Amber/app
greenart7c3 1056fb39db Fix NegativeArraySizeException crash in relay subscriptions
ProfileSubscription and NotificationSubscription kept their subscription
state in plain LinkedHashMaps that are mutated from UI/coroutine threads
(updateFilter, closeSub, updateFilters) while relay I/O threads iterate
them in onIncomingMessage. Iterating a LinkedHashMap's values/entries
while another thread structurally modifies it crashes with
NegativeArraySizeException on Android, e.g. from
ProfileSubscription.updateFilters via checkForNewRelaysAndUpdateAllFilters.

- Use ConcurrentHashMap for all shared maps in both subscriptions and
  concurrent key sets for the per-subscription relay sets
- Replace containsKey + get(!!) with an atomic getOrPut in
  NotificationSubscription.updateFilter

Add unit tests: functional coverage for the subscribe/unsubscribe
lifecycle and concurrency regression tests that reliably reproduce the
race on the pre-fix implementation.
2026-07-29 07:06:07 -03:00
..
2024-03-01 06:56:32 -03:00
2023-07-26 16:44:33 -03:00