Merge "Merge branch 'stable-2.13'"

This commit is contained in:
David Pursehouse 2016-12-10 13:07:48 +00:00 committed by Gerrit Code Review
commit da1c5443ab
1 changed files with 11 additions and 0 deletions

View File

@ -259,6 +259,17 @@ public class AccountManager {
try {
db.accounts().upsert(Collections.singleton(account));
AccountExternalId existingExtId =
db.accountExternalIds().get(extId.getKey());
if (existingExtId != null
&& !existingExtId.getAccountId().equals(extId.getAccountId())) {
// external ID is assigned to another account, do not overwrite
db.accounts().delete(Collections.singleton(account));
throw new AccountException(
"Cannot assign external ID \"" + extId.getExternalId()
+ "\" to account " + newId + "; external ID already in use.");
}
db.accountExternalIds().upsert(Collections.singleton(extId));
} finally {
// If adding the account failed, it may be that it actually was the