Mastercard / flow

Testing framework

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Message field defensive copies

therealryan opened this issue · comments

The message types are rightfully strict about accepting mutable types as field values - the problems that arise when a value is mutated unexpectedly are painful to debug.
Right now the defence is just an allow-list of immutable types, but an additional approach would be to register functions that make defensive copies, to be used when values are taken into and supplied out of message instances.

This would allow much more natural handling of mutable types that are heavily tied into common messages (looking at you, java.sql.Timestamp).