Skip to content

MS-241/fix: Prevent infinite loops in Order entity relationships

salaheddine zidani a demandé de fusionner feature/MS-241 vers develop

Problem

Entity classes in the Order domain had bidirectional relationships without proper exclusions in toString() and equals() methods, causing potential infinite loops and stack overflow errors during:

  • Logging operations
  • Debugging sessions
  • Entity comparisons

Solution

Added @ToString.Exclude and @EqualsAndHashCode.Exclude annotations to all bidirectional relationships:

Modified Entities

  • Order: Excluded collections (orderLines, notes, editHistory, orderStatusHistories, refundOrders, giftCards)
  • OrderLine: Excluded order parent reference
  • Note: Excluded order parent reference
  • EditHistory: Excluded order parent reference
  • OrderStatusHistory: Excluded order parent reference
  • RefundOrder: Excluded refundOrderLines collection and order reference
  • RefundOrderLine: Excluded refundOrder and orderLine references

Impact

No breaking changes - business logic unchanged
Safer logging - toString() no longer causes stack overflow
Better performance - equals() and hashCode() more efficient
Cleaner logs - entity output is concise and readable

Testing

  • Verified all entities compile successfully
  • Confirmed no impact on existing unit tests
  • Validated toString() output is safe and readable
  • Checked equals() and hashCode() behavior

Related Issues

Closes MS-241

Rapports de requête de fusion