if (userId != null) {
if (task.getAssignee() != null) {
if (!task.getAssignee().equals(userId)) {
// When the task is already claimed by another user, throw exception. Otherwise, ignore
// this, post-conditions of method already met.
throw new TaskAlreadyClaimedException(task.getId(), task.getAssignee());
}
} else {
task.setAssignee(userId);
}
} else {