SetAssigneeOp fails to detect identical assignee.

Also removed unnecessary null checks for optional objects.

Change-Id: Ia1f6218b75dcaea751c089eab29a5a285c2c6b8d
This commit is contained in:
Gustaf Lundh
2016-09-23 14:45:33 +02:00
committed by David Pursehouse
parent cc6a0cd4ee
commit 0e907f9812

View File

@@ -78,18 +78,18 @@ public class SetAssigneeOp extends BatchUpdate.Op {
Optional<Account.Id> oldAssigneeId =
Optional.fromNullable(ctx.getChange().getAssignee());
if (input.assignee == null) {
if (oldAssigneeId != null && oldAssigneeId.isPresent()) {
if (oldAssigneeId.isPresent()) {
throw new BadRequestException("Cannot set Assignee to empty");
}
return false;
}
Account oldAssignee = null;
if (oldAssigneeId != null && oldAssigneeId.isPresent()) {
if (oldAssigneeId.isPresent()) {
oldAssignee = accountInfosFactory.create().get(oldAssigneeId.get());
}
IdentifiedUser newAssigneeUser = accounts.parse(input.assignee);
if (oldAssigneeId != null &&
oldAssigneeId.equals(newAssigneeUser.getAccountId())) {
if (oldAssigneeId.isPresent() &&
oldAssigneeId.get().equals(newAssigneeUser.getAccountId())) {
newAssignee = oldAssignee;
return false;
}