mirror of
https://github.com/greenart7c3/Amber.git
synced 2026-10-06 03:18:23 +00:00
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.