cloud-notifications: fix NPE on assignee removed
Change-Id: Ie14505e8e068142f9bc7d69e027d7101fe9df4db
Signed-off-by: Jorge Ruesga <j.ruesga.criado@gmail.com>
(cherry picked from commit 2eb77d8bbdbfeac285ebecdc8cdeb1a9d595df73)
diff --git a/src/main/java/com/ruesga/gerrit/plugins/fcm/handlers/AssigneeChangedEventHandler.java b/src/main/java/com/ruesga/gerrit/plugins/fcm/handlers/AssigneeChangedEventHandler.java
index 9ae578e..fa050ea 100644
--- a/src/main/java/com/ruesga/gerrit/plugins/fcm/handlers/AssigneeChangedEventHandler.java
+++ b/src/main/java/com/ruesga/gerrit/plugins/fcm/handlers/AssigneeChangedEventHandler.java
@@ -74,10 +74,15 @@
assignee._new = event.getChange().assignee;
Notification notification = createNotification(event);
notification.extra = getSerializer().toJson(assignee);
- notification.body = formatAccount(event.getWho())
- + " change assignee to "
- + formatAccount(event.getChange().assignee)
- + " on this change";
+ if (assignee._new == null) {
+ notification.body = formatAccount(event.getWho())
+ + " unassigned " + formatAccount(assignee.old)
+ + " from this change";
+ } else {
+ notification.body = formatAccount(event.getWho())
+ + " assigned " + formatAccount(assignee._new)
+ + " to this change";
+ }
notify(notification, event);
}