mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 16:07:15 +02:00
Fix NPE bug in DomainCommand.cloneAndLinkReferences()
See b/30806813 for more context. Copied from there: This appears to be happening if we get an EPP domain create command that is missing any contacts (but has a registrant; with no registrant we exercise a different codepath). In that case, JAXB leaves the contacts field on the Create null, and we try to pass it into Sets.union() as a result of Corey's refactoring in [] that changed contact loading to load the contacts and registrant all at once. The fix is just to apply nullToEmpty() first. Note that it's always an error to try to create a domain without any non-registrant contacts, but that's supposed to happen later on in BaseDomainCreateFlow.verifyCreateIsAllowed() via validateRequiredContactsPresent(), which will produce a nice error message. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=130309019
This commit is contained in:
parent
160266f37a
commit
d1ea3e3a68
7 changed files with 178 additions and 3 deletions
|
@ -22,7 +22,9 @@ import static com.google.common.collect.Sets.difference;
|
|||
import static com.google.common.collect.Sets.intersection;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.util.CollectionUtils.difference;
|
||||
import static google.registry.util.CollectionUtils.forceEmptyToNull;
|
||||
import static google.registry.util.CollectionUtils.nullSafeImmutableCopy;
|
||||
import static google.registry.util.CollectionUtils.nullToEmpty;
|
||||
import static google.registry.util.CollectionUtils.nullToEmptyImmutableCopy;
|
||||
import static google.registry.util.CollectionUtils.union;
|
||||
|
||||
|
@ -204,12 +206,12 @@ public class DomainCommand {
|
|||
registrantPlaceholder.contactId = clone.registrantContactId;
|
||||
registrantPlaceholder.type = DesignatedContact.Type.REGISTRANT;
|
||||
Set<DesignatedContact> contacts = linkContacts(
|
||||
union(clone.foreignKeyedDesignatedContacts, registrantPlaceholder),
|
||||
union(nullToEmpty(clone.foreignKeyedDesignatedContacts), registrantPlaceholder),
|
||||
now);
|
||||
for (DesignatedContact contact : contacts) {
|
||||
if (DesignatedContact.Type.REGISTRANT.equals(contact.getType())) {
|
||||
clone.registrant = contact.getContactRef();
|
||||
clone.contacts = difference(contacts, contact);
|
||||
clone.contacts = forceEmptyToNull(difference(contacts, contact));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -511,6 +513,7 @@ public class DomainCommand {
|
|||
private final Class<?> type;
|
||||
|
||||
InvalidReferencesException(Class<?> type, ImmutableSet<String> foreignKeys) {
|
||||
super(String.format("Invalid %s reference IDs: %s", type.getSimpleName(), foreignKeys));
|
||||
this.type = checkNotNull(type);
|
||||
this.foreignKeys = foreignKeys;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue