This is a port of #1501 into master branch. Here is a full description of the ported PR.
This changeset addresses #1499 by disallowing to call state() method from aggregate appliers.
Previously, end-users could rely on Aggregate.state() from @Apply-ers. However, in some cases (such as the one described in #1499) state() does not reflect the last state of an aggregate. This is so because appliers are invoked in scope of a single transaction — be it when loading an aggregate instance from storage, or when applying the just-emitted events during the command dispatching. Until such a transaction is completed, state() does not reflect the model updates corresponding to the respective domain events. Using the returned state value most likely leads to bugs.
The designed way has always been to use builder() instead of state(), because it is kept up-to-date throughout the active aggregate transaction.
Therefore, once this PR is merged, any calls to state() from @Apply-annotated method will lead to an IllegalStateException.
This is a port of #1501 into
master
branch. Here is a full description of the ported PR.This changeset addresses #1499 by disallowing to call
state()
method from aggregate appliers.Previously, end-users could rely on
Aggregate.state()
from@Apply
-ers. However, in some cases (such as the one described in #1499)state()
does not reflect the last state of an aggregate. This is so because appliers are invoked in scope of a single transaction — be it when loading an aggregate instance from storage, or when applying the just-emitted events during the command dispatching. Until such a transaction is completed,state()
does not reflect the model updates corresponding to the respective domain events. Using the returned state value most likely leads to bugs.The designed way has always been to use
builder()
instead ofstate()
, because it is kept up-to-date throughout the active aggregate transaction.Therefore, once this PR is merged, any calls to
state()
from@Apply
-annotated method will lead to anIllegalStateException
.The library version is set to
2.0.0-SNAPSHOT.145
.