AddMembers.apply: Prevent NPE when account doesn't exist

When trying to add an account to a group, if the account doesn't
exist yet and cannot be created, AddMembers.apply() would throw
an NPE. Fix it to throw UnprocessableEntityException instead,
which is handled by RestApiServlet.

Signed-off-by: Jay Soffian <jaysoffian@gmail.com>
Change-Id: I724a7b8a95a8df70506ae591575c74153278adc4
This commit is contained in:
Jay Soffian
2014-08-13 12:00:06 -04:00
parent 4745a16a8b
commit 4f1f3313a3

View File

@@ -163,7 +163,10 @@ public class AddMembers implements RestModifyView<GroupResource, Input> {
case LDAP:
if (accountResolver.find(nameOrEmail) == null) {
// account does not exist, try to create it
return createAccountByLdap(nameOrEmail);
Account a = createAccountByLdap(nameOrEmail);
if (a != null) {
return a;
}
}
break;
default: