You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Rework logic in addMyItemIdToCoveringItem to support immutable SpecificationItem #540
Currently, the method addMyItemIdToCoveringItem in LinkedSpecificationItem.java attempts to modify the list of covered IDs directly on the underlying SpecificationItem object:
However, SpecificationItem is designed to be immutable, and its coveredIds list is wrapped in Collections.unmodifiableList during construction:
// In SpecificationItem.java constructorthis.coveredIds = Collections.unmodifiableList(builder.coveredIds);
This leads to an UnsupportedOperationException when addMyItemIdToCoveringItem is called on a real SpecificationItem (unless the list already contains the ID).
Proposed Solution
The logic for establishing bidirectional links should be moved entirely into the LinkedSpecificationItem or the Linker class. LinkedSpecificationItem already maintains its own links map which should be used to track these relationships.
Specifically:
Remove addMyItemIdToCoveringItem from LinkedSpecificationItem.
Ensure that all necessary linking (including back-links) is handled via addLinkToItemWithStatus or a similar mechanism that operates on LinkedSpecificationItem objects rather than modifying the base SpecificationItem model.
Review LinkedSpecificationItem.getCoveredIds() to ensure it correctly aggregates information from both the base item and any links established during the linking phase, if necessary.
Activity