Support noticed unstable behavior in a small function that prepares a snapshot of recipient groups for later notification delivery. After a recent change, the saved result sometimes changes unexpectedly, and saving again with the same key behaves unpredictably.
saveSnapshot function must save an independent copy of the recipient list for each key.loadSnapshot must not change because of later modifications to the caller’s input collections.saveSnapshot with the same groupId must replace the saved snapshot with a new set of recipients.scalac RecipientGroupStore.scala Demo.scala && scala Demo
clear and subsequent addition of elements to the original ListBuffer.groupId again, the old snapshot is completely replaced by the new one.loadSnapshot("ops") returns only the current unique non-empty addresses.3.3.121scalac and execution via scalaUse line comments to explain the problem, its impact, the fix and how to test it.