Events in Axon Framework passed by reference to the Eventhandlers

Hello,

we just encountered a rather tricky bug but could identify the problem now. It seems that the events passed to our eventhandlers are stored in some kind of cache and one eventhandler modifiyingEventHandler used one of the objects in the event and changed a parameter.

now the other eventhandler “otherEventHandler” got a event reference where the value was changed also, however the change happened by accident (or at least we thought the events passed to be immutable) so now there is a race condition within the application yielding different outcomes depending on what event handler comes first.

Now to my question: Is there a way to configure the event handling in such a way, that event payloads are always passed as a copy and not by reference so these issues never happen? In our application we just identified this one problem for now, but these issues are hard to pin point exactly since it may be a long time until they are occuring.