davsclaus commented on code in PR #26852:
URL: https://github.com/apache/camel/pull/26852#discussion_r4093494585


##########
core/camel-support/src/main/java/org/apache/camel/support/CopyOnWriteHeadersMap.java:
##########
@@ -485,6 +488,55 @@ public String toString() {
     /**
      * A COW-aware Set wrapper for entrySet() that triggers copy-on-write for 
mutating operations.
      */

Review Comment:
   Fixed in 52ade950efaf: the entry set Javadoc is back above 
`CopyOnWriteEntrySet`, and `CopyOnWriteEntry` keeps its own.
   
   _Claude Code on behalf of Claus Ibsen_



##########
core/camel-support/src/main/java/org/apache/camel/support/CopyOnWriteHeadersMap.java:
##########
@@ -505,14 +557,27 @@ public boolean contains(Object o) {
 
         @Override
         public Object[] toArray() {
+            if (shared) {
+                // the entries of a shared map must be wrapped, so setValue 
does not change the shared map
+                return toList().toArray();
+            }
             return delegate.entrySet().toArray();
         }
 
         @Override
         public <T> T[] toArray(T[] a) {
+            if (shared) {
+                return toList().toArray(a);
+            }
             return delegate.entrySet().toArray(a);
         }

Review Comment:
   Added in 52ade950efaf: `testCopyOnWriteEntrySetTypedToArraySetValue` uses 
`toArray(new Map.Entry[0])`. It fails without the fix, like the other three 
tests.
   
   On the `port/camel-4.22.x` label: I'll leave the backport decision to the 
committers.
   
   _Claude Code on behalf of Claus Ibsen_



-- 
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