added comment regarding potential race condition

This commit is contained in:
Michael Hoennig 2019-04-12 17:34:28 +02:00
parent 73969f5a40
commit 3e66a21805

View File

@ -18,6 +18,8 @@ public class MembershipValidator {
throw new BadRequestAlertException("Invalid untilDate", Membership.ENTITY_NAME, "untilDateMustBeAfterSinceDate");
}
// It's known that this validation can cause a race condition if two memberships of the same customer are saved at
// same time (overlapping transactions). This is ignored in this case because it's too unlikely to be worth the effort.
if (membershipRepository.hasUncancelledMembershipForCustomer(membershipDTO.getCustomerId())) {
throw new BadRequestAlertException("Another uncancelled membership exists", Membership.ENTITY_NAME, "anotherUncancelledMembershipExists");
}