wenjin272 commented on code in PR #1138:
URL: https://github.com/apache/flink-agents/pull/1138#discussion_r4228420599


##########
runtime/src/main/java/org/apache/flink/agents/runtime/memory/MemoryObjectImpl.java:
##########
@@ -259,6 +259,17 @@ public static final class MemoryItem implements 
Serializable {
             this.subKeys = new HashSet<>();
         }
 
+        /**
+         * Copy constructor producing an item with an independent {@code 
subKeys} set. Used at the
+         * child-memory isolation boundary so the field-list updates that 
{@link #set} and {@link
+         * #fillParents} apply in place stay confined to the copy's own scope.
+         */
+        MemoryItem(MemoryItem other) {
+            this.type = other.type;
+            this.value = other.value;

Review Comment:
   Thanks for the update. I reran the mutable-list reproducer on `7dca9eb`, and 
the parent value still changes. `IsolatedCachedMemoryStore.get()` returns the 
parent's item, and `MemoryItem.getValue()` exposes the same payload reference. 
Making that reference `final` does not make the list/map immutable:
   
   ```java
   List<String> items = (List<String>) child.get("items").getValue();
   items.add("child"); // Already mutates the parent's list, before child.set().
   ```
   
   The copy-on-write change protects `subKeys`, but this path bypasses it. 
Could we also isolate mutable payloads and add a regression test asserting that 
modifying a list obtained through child memory leaves the parent's value 
unchanged?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to