In the service for tracking connected devices, the session model and the registry update logic were changed. After that, repeated updates of the same session started producing unexpected results: some data stopped accumulating, and in some scenarios extra entries appeared in the registry.
You need to review the changes and find exactly two independent regressions in the after version of the code.
sessionId in the registry.owner,scopes with new values,sessionId.snapshot() must be safe to read from outside and must not allow the internal registry state to be modified through returned objects.javac src/*.java
java -cp src Demo
snapshot() behaves when data from the returned list is modified externally.upserts for one sessionId, only one record remains in the registry.scopes from both updates.owner matches the latest update.snapshot() does not change the registry state.javac src/*.javajava -cp src Demosrc directoryUse line comments to explain the problem, its impact, the fix and how to test it.