diff --git a/java/google/registry/rdap/RdapJsonFormatter.java b/java/google/registry/rdap/RdapJsonFormatter.java index 7eec9ca60..fab91dc21 100644 --- a/java/google/registry/rdap/RdapJsonFormatter.java +++ b/java/google/registry/rdap/RdapJsonFormatter.java @@ -522,10 +522,13 @@ public class RdapJsonFormatter { Map, HostResource> loadedHosts = ofy().load().keys(domainResource.getNameservers()); // Load the registrant and other contacts and add them to the data. - if (displayContacts) { + ImmutableList> entities; + if (!displayContacts) { + entities = ImmutableList.of(); + } else { Map, ContactResource> loadedContacts = ofy().load().keys(domainResource.getReferencedContacts()); - ImmutableList> entities = + entities = Streams.concat( domainResource.getContacts().stream(), Stream.of( @@ -543,17 +546,17 @@ public class RdapJsonFormatter { outputDataType, authorization)) .collect(toImmutableList()); - entities = - addRegistrarEntity( - entities, - domainResource.getCurrentSponsorClientId(), - linkBase, - whoisServer, - now, - outputDataType); - if (!entities.isEmpty()) { - jsonBuilder.put("entities", entities); - } + } + entities = + addRegistrarEntity( + entities, + domainResource.getCurrentSponsorClientId(), + linkBase, + whoisServer, + now, + outputDataType); + if (!entities.isEmpty()) { + jsonBuilder.put("entities", entities); } // Add the nameservers to the data; the load was kicked off above for efficiency. ImmutableList.Builder nsBuilder = new ImmutableList.Builder<>(); diff --git a/javatests/google/registry/rdap/RdapDomainSearchActionTest.java b/javatests/google/registry/rdap/RdapDomainSearchActionTest.java index 12a5c901b..f7290252d 100644 --- a/javatests/google/registry/rdap/RdapDomainSearchActionTest.java +++ b/javatests/google/registry/rdap/RdapDomainSearchActionTest.java @@ -1022,7 +1022,7 @@ public class RdapDomainSearchActionTest extends RdapSearchActionTestCase { "21-EXAMPLE", null, ImmutableList.of("ns1.cat.lol", "ns2.external.tld"), - "Yes Virginia