You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "OldTruckDriver (via GitHub)" <gi...@apache.org> on 2026/06/19 14:47:40 UTC

[PR] [COLLECTIONS-892] Fix unique IndexedCollection add atomicity [commons-collections]

OldTruckDriver opened a new pull request, #688:
URL: https://github.com/apache/commons-collections/pull/688

   [COLLECTIONS-892] Fix unique IndexedCollection add atomicity
   
   IndexedCollection#add(Object) updated the decorated collection before checking the unique index constraint. If a duplicate transformed key was rejected, the exception was thrown after the decorated collection had already been mutated, leaving the collection and index out of sync.
   
   This change checks duplicate keys before mutating the decorated collection for unique indexed collections. Non-unique indexed collections keep the existing add path.
   
   Tests cover a failed unique add where "01" and "1" map to the same key, and verify that the decorated collection and index still contain only the original value.
   
   Tests run:
   - mvn -q -Dtest=org.apache.commons.collections4.collection.IndexedCollectionTest#testFailedUniqueAddDoesNotPolluteDecoratedCollection test
   - mvn -q -Dtest=org.apache.commons.collections4.collection.IndexedCollectionTest test
   - mvn -q
   - git diff --check


-- 
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: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [COLLECTIONS-892] Fix unique IndexedCollection add atomicity [commons-collections]

Posted by "garydgregory (via GitHub)" <gi...@apache.org>.
garydgregory commented on PR #688:
URL: https://github.com/apache/commons-collections/pull/688#issuecomment-4753593657

   Jira ticket is [COLLECTIONS-892](https://issues.apache.org/jira/browse/COLLECTIONS-892).


-- 
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: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [COLLECTIONS-892] Fix unique IndexedCollection add atomicity [commons-collections]

Posted by "garydgregory (via GitHub)" <gi...@apache.org>.
garydgregory commented on PR #688:
URL: https://github.com/apache/commons-collections/pull/688#issuecomment-4753641856

   Hello @OldTruckDriver 
   In the future, please consider simpler code like 3cb647e7eadba3f9d6dcb8a566d52f78134061e9
   


-- 
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: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [COLLECTIONS-892] Fix unique IndexedCollection add atomicity [commons-collections]

Posted by "garydgregory (via GitHub)" <gi...@apache.org>.
garydgregory merged PR #688:
URL: https://github.com/apache/commons-collections/pull/688


-- 
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: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org