Include more info in host/domain name failures (#1346)

We're seeing some of these in CreateSyntheticHistoryEntriesAction and I
can't tell why from the logs (it doesn't appear to print the repo ID or
domain/host name)
This commit is contained in:
gbrodman 2021-10-08 15:17:22 -04:00 committed by GitHub
parent 72a70bebe7
commit 8d5c12dae4
5 changed files with 12 additions and 10 deletions

View file

@ -865,7 +865,8 @@ public class DomainContent extends EppResource
public B setDomainName(String domainName) { public B setDomainName(String domainName) {
checkArgument( checkArgument(
domainName.equals(canonicalizeDomainName(domainName)), domainName.equals(canonicalizeDomainName(domainName)),
"Domain name must be in puny-coded, lower-case form"); "Domain name %s not in puny-coded, lower-case form",
domainName);
getInstance().fullyQualifiedDomainName = domainName; getInstance().fullyQualifiedDomainName = domainName;
return thisCastToDerived(); return thisCastToDerived();
} }

View file

@ -196,7 +196,8 @@ public class HostBase extends EppResource {
public B setHostName(String hostName) { public B setHostName(String hostName) {
checkArgument( checkArgument(
hostName.equals(canonicalizeDomainName(hostName)), hostName.equals(canonicalizeDomainName(hostName)),
"Host name must be in puny-coded, lower-case form"); "Host name %s not in puny-coded, lower-case form",
hostName);
getInstance().fullyQualifiedHostName = hostName; getInstance().fullyQualifiedHostName = hostName;
return thisCastToDerived(); return thisCastToDerived();
} }

View file

@ -83,12 +83,12 @@ public class CreateSyntheticHistoryEntriesAction implements Runnable {
} }
/** /**
* The number of shards to run the map-only mapreduce on. * The default number of shards to run the map-only mapreduce on.
* *
* <p>This is much lower than the default of 100, or even 10, because we can afford it being slow * <p>This is much lower than the default of 100 because we can afford it being slow and we want
* and we want to avoid overloading SQL. * to avoid overloading SQL.
*/ */
private static final int NUM_SHARDS = 3; private static final int NUM_SHARDS = 10;
@Override @Override
public void run() { public void run() {

View file

@ -696,7 +696,7 @@ public class DomainBaseTest extends EntityTestCase {
IllegalArgumentException.class, () -> domain.asBuilder().setDomainName("AAA.BBB")); IllegalArgumentException.class, () -> domain.asBuilder().setDomainName("AAA.BBB"));
assertThat(thrown) assertThat(thrown)
.hasMessageThat() .hasMessageThat()
.contains("Domain name must be in puny-coded, lower-case form"); .isEqualTo("Domain name AAA.BBB not in puny-coded, lower-case form");
} }
@Test @Test
@ -706,7 +706,7 @@ public class DomainBaseTest extends EntityTestCase {
IllegalArgumentException.class, () -> domain.asBuilder().setDomainName("みんな.みんな")); IllegalArgumentException.class, () -> domain.asBuilder().setDomainName("みんな.みんな"));
assertThat(thrown) assertThat(thrown)
.hasMessageThat() .hasMessageThat()
.contains("Domain name must be in puny-coded, lower-case form"); .isEqualTo("Domain name みんな.みんな not in puny-coded, lower-case form");
} }
@Test @Test

View file

@ -200,7 +200,7 @@ class HostResourceTest extends EntityTestCase {
IllegalArgumentException.class, () -> host.asBuilder().setHostName("AAA.BBB.CCC")); IllegalArgumentException.class, () -> host.asBuilder().setHostName("AAA.BBB.CCC"));
assertThat(thrown) assertThat(thrown)
.hasMessageThat() .hasMessageThat()
.contains("Host name must be in puny-coded, lower-case form"); .isEqualTo("Host name AAA.BBB.CCC not in puny-coded, lower-case form");
} }
@TestOfyAndSql @TestOfyAndSql
@ -210,7 +210,7 @@ class HostResourceTest extends EntityTestCase {
IllegalArgumentException.class, () -> host.asBuilder().setHostName("みんな.みんな.みんな")); IllegalArgumentException.class, () -> host.asBuilder().setHostName("みんな.みんな.みんな"));
assertThat(thrown) assertThat(thrown)
.hasMessageThat() .hasMessageThat()
.contains("Host name must be in puny-coded, lower-case form"); .isEqualTo("Host name みんな.みんな.みんな not in puny-coded, lower-case form");
} }
@TestOfyAndSql @TestOfyAndSql