mirror of
https://github.com/google/nomulus.git
synced 2025-07-12 14:08:18 +02:00
Filter out empty dsData objects, not just null ones (#1449)
* Filter out empty dsData objects, not just null ones Hibernate/SQL will get mad if the digest is null or empty, and previously we only check for null. We should filter out empty digests as well.
This commit is contained in:
parent
fb8864acef
commit
c45f6bf385
3 changed files with 36 additions and 2 deletions
|
@ -170,7 +170,10 @@ public class DomainBase extends DomainContent
|
||||||
@Override
|
@Override
|
||||||
public void beforeSqlSaveOnReplay() {
|
public void beforeSqlSaveOnReplay() {
|
||||||
fullyQualifiedDomainName = DomainNameUtils.canonicalizeDomainName(fullyQualifiedDomainName);
|
fullyQualifiedDomainName = DomainNameUtils.canonicalizeDomainName(fullyQualifiedDomainName);
|
||||||
dsData = dsData.stream().filter(datum -> datum.getDigest() != null).collect(toImmutableSet());
|
dsData =
|
||||||
|
dsData.stream()
|
||||||
|
.filter(datum -> datum.getDigest() != null && datum.getDigest().length > 0)
|
||||||
|
.collect(toImmutableSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -318,7 +318,7 @@ public class DomainHistory extends HistoryEntry implements SqlEntity {
|
||||||
domainHistory.nsHosts = nullToEmptyImmutableCopy(domainHistory.domainContent.nsHosts);
|
domainHistory.nsHosts = nullToEmptyImmutableCopy(domainHistory.domainContent.nsHosts);
|
||||||
domainHistory.dsDataHistories =
|
domainHistory.dsDataHistories =
|
||||||
nullToEmptyImmutableCopy(domainHistory.domainContent.getDsData()).stream()
|
nullToEmptyImmutableCopy(domainHistory.domainContent.getDsData()).stream()
|
||||||
.filter(dsData -> dsData.getDigest() != null)
|
.filter(dsData -> dsData.getDigest() != null && dsData.getDigest().length > 0)
|
||||||
.map(dsData -> DomainDsDataHistory.createFrom(domainHistory.id, dsData))
|
.map(dsData -> DomainDsDataHistory.createFrom(domainHistory.id, dsData))
|
||||||
.collect(toImmutableSet());
|
.collect(toImmutableSet());
|
||||||
domainHistory.gracePeriodHistories =
|
domainHistory.gracePeriodHistories =
|
||||||
|
|
|
@ -291,6 +291,37 @@ public class DomainHistoryTest extends EntityTestCase {
|
||||||
.isEqualTo("xn--kittyat-yxa.tld");
|
.isEqualTo("xn--kittyat-yxa.tld");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestSqlOnly
|
||||||
|
void testFillingHistory_missingDigest() {
|
||||||
|
createTld("tld");
|
||||||
|
DomainBase baseDomain = createDomainWithContactsAndHosts();
|
||||||
|
DomainBase domain =
|
||||||
|
baseDomain
|
||||||
|
.asBuilder()
|
||||||
|
.setDsData(
|
||||||
|
ImmutableSet.of(
|
||||||
|
DelegationSignerData.create(0, 1, 2, new byte[] {}, baseDomain.getRepoId()),
|
||||||
|
DelegationSignerData.create(3, 4, 5, null, baseDomain.getRepoId())))
|
||||||
|
.build();
|
||||||
|
DomainHistory domainHistory =
|
||||||
|
new DomainHistory.Builder()
|
||||||
|
.setDomainRepoId(domain.getRepoId())
|
||||||
|
.setRegistrarId(domain.getCurrentSponsorRegistrarId())
|
||||||
|
.setModificationTime(fakeClock.nowUtc())
|
||||||
|
.setType(HistoryEntry.Type.DOMAIN_CREATE)
|
||||||
|
.build();
|
||||||
|
jpaTm()
|
||||||
|
.transact(
|
||||||
|
() -> {
|
||||||
|
domain.beforeSqlSaveOnReplay();
|
||||||
|
jpaTm().put(domain);
|
||||||
|
domainHistory.beforeSqlSaveOnReplay();
|
||||||
|
jpaTm().put(domainHistory);
|
||||||
|
});
|
||||||
|
assertThat(DatabaseHelper.loadByEntity(domain).getDsData()).isEmpty();
|
||||||
|
assertThat(DatabaseHelper.loadByEntity(domainHistory).getDsDataHistories()).isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
static DomainBase createDomainWithContactsAndHosts() {
|
static DomainBase createDomainWithContactsAndHosts() {
|
||||||
createTld("tld");
|
createTld("tld");
|
||||||
HostResource host = newHostResourceWithRoid("ns1.example.com", "host1");
|
HostResource host = newHostResourceWithRoid("ns1.example.com", "host1");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue