mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 16:07:15 +02:00
Fix NPE in registry_tool when creating or updating a TLD with a dns writer
I forgot to inject the CreateTldCommand/UpdateTldCommand commands, which now need to be injected so that the list of available DnsWriter implementations is instantiated. This CL also adds a new DI Set<String> with just the name of the writer, so that the instantiated writer map (which may have many DI dependencies) doesn't need to be pulled in. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=130042215
This commit is contained in:
parent
0cab13e6d8
commit
e55ed209c5
6 changed files with 58 additions and 21 deletions
|
@ -17,7 +17,9 @@ package google.registry.dns.writer;
|
|||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
import dagger.multibindings.IntoMap;
|
||||
import dagger.multibindings.IntoSet;
|
||||
import dagger.multibindings.StringKey;
|
||||
import javax.inject.Named;
|
||||
|
||||
/** Dagger module that disables DNS updates. */
|
||||
@Module
|
||||
|
@ -26,7 +28,14 @@ public final class VoidDnsWriterModule {
|
|||
@Provides
|
||||
@IntoMap
|
||||
@StringKey(VoidDnsWriter.NAME)
|
||||
static DnsWriter provideVoidDnsWriter(VoidDnsWriter writer) {
|
||||
static DnsWriter provideWriter(VoidDnsWriter writer) {
|
||||
return writer;
|
||||
}
|
||||
|
||||
@Provides
|
||||
@IntoSet
|
||||
@Named("dnsWriterNames")
|
||||
static String provideWriterName() {
|
||||
return VoidDnsWriter.NAME;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,10 +23,12 @@ import com.google.common.base.Function;
|
|||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
import dagger.multibindings.IntoMap;
|
||||
import dagger.multibindings.IntoSet;
|
||||
import dagger.multibindings.StringKey;
|
||||
import google.registry.config.ConfigModule.Config;
|
||||
import google.registry.dns.writer.DnsWriter;
|
||||
import java.util.Set;
|
||||
import javax.inject.Named;
|
||||
|
||||
/** Dagger module for Google Cloud DNS service connection objects. */
|
||||
@Module
|
||||
|
@ -46,7 +48,14 @@ public final class CloudDnsModule {
|
|||
@Provides
|
||||
@IntoMap
|
||||
@StringKey(CloudDnsWriter.NAME)
|
||||
static DnsWriter provideCloudDnsWriter(CloudDnsWriter writer) {
|
||||
static DnsWriter provideWriter(CloudDnsWriter writer) {
|
||||
return writer;
|
||||
}
|
||||
|
||||
@Provides
|
||||
@IntoSet
|
||||
@Named("dnsWriterNames")
|
||||
static String provideWriterName() {
|
||||
return CloudDnsWriter.NAME;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,8 +17,10 @@ package google.registry.dns.writer.dnsupdate;
|
|||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
import dagger.multibindings.IntoMap;
|
||||
import dagger.multibindings.IntoSet;
|
||||
import dagger.multibindings.StringKey;
|
||||
import google.registry.dns.writer.DnsWriter;
|
||||
import javax.inject.Named;
|
||||
import javax.net.SocketFactory;
|
||||
|
||||
/** Dagger module that provides a DnsUpdateWriter. */
|
||||
|
@ -33,7 +35,14 @@ public abstract class DnsUpdateWriterModule {
|
|||
@Provides
|
||||
@IntoMap
|
||||
@StringKey(DnsUpdateWriter.NAME)
|
||||
static DnsWriter provideDnsUpdateWriter(DnsUpdateWriter writer) {
|
||||
static DnsWriter provideWriter(DnsUpdateWriter writer) {
|
||||
return writer;
|
||||
}
|
||||
|
||||
@Provides
|
||||
@IntoSet
|
||||
@Named("dnsWriterNames")
|
||||
static String provideWriterName() {
|
||||
return DnsUpdateWriter.NAME;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,6 +46,8 @@ java_library(
|
|||
"//java/google/registry/bigquery",
|
||||
"//java/google/registry/config",
|
||||
"//java/google/registry/dns/writer",
|
||||
"//java/google/registry/dns/writer/clouddns",
|
||||
"//java/google/registry/dns/writer/dnsupdate",
|
||||
"//java/google/registry/export",
|
||||
"//java/google/registry/flows",
|
||||
"//java/google/registry/keyring/api",
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
package google.registry.tools;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static google.registry.model.RoidSuffixes.isRoidSuffixUsed;
|
||||
import static google.registry.util.CollectionUtils.findDuplicates;
|
||||
import static google.registry.util.DomainNameUtils.canonicalizeDomainName;
|
||||
|
@ -27,7 +26,6 @@ import com.google.common.base.Optional;
|
|||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.ImmutableSortedMap;
|
||||
import google.registry.dns.writer.DnsWriter;
|
||||
import google.registry.model.pricing.StaticPremiumListPricingEngine;
|
||||
import google.registry.model.registry.Registries;
|
||||
import google.registry.model.registry.Registry;
|
||||
|
@ -43,6 +41,7 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import org.joda.money.Money;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.Duration;
|
||||
|
@ -50,11 +49,11 @@ import org.joda.time.Duration;
|
|||
/** Shared base class for commands to create or update a TLD. */
|
||||
abstract class CreateOrUpdateTldCommand extends MutatingCommand {
|
||||
|
||||
@Inject Map<String, DnsWriter> dnsWriters;
|
||||
@Inject
|
||||
@Named("dnsWriterNames")
|
||||
Set<String> dnsWriterNames;
|
||||
|
||||
@Parameter(
|
||||
description = "Names of the TLDs",
|
||||
required = true)
|
||||
@Parameter(description = "Names of the TLDs", required = true)
|
||||
List<String> mainParameters;
|
||||
|
||||
@Parameter(
|
||||
|
@ -384,8 +383,8 @@ abstract class CreateOrUpdateTldCommand extends MutatingCommand {
|
|||
|
||||
if (dnsWriter != null) {
|
||||
if (dnsWriter.isPresent()) {
|
||||
checkNotNull(
|
||||
dnsWriters.get(dnsWriter.get()),
|
||||
checkArgument(
|
||||
dnsWriterNames.contains(dnsWriter.get()),
|
||||
"The DNS writer '%s' doesn't exist",
|
||||
dnsWriter.get());
|
||||
builder.setDnsWriter(dnsWriter.get());
|
||||
|
|
|
@ -16,6 +16,9 @@ package google.registry.tools;
|
|||
|
||||
import dagger.Component;
|
||||
import google.registry.config.ConfigModule;
|
||||
import google.registry.dns.writer.VoidDnsWriterModule;
|
||||
import google.registry.dns.writer.clouddns.CloudDnsModule;
|
||||
import google.registry.dns.writer.dnsupdate.DnsUpdateWriterModule;
|
||||
import google.registry.keyring.api.KeyModule;
|
||||
import google.registry.keyring.api.VoidKeyringModule;
|
||||
import google.registry.request.Modules.DatastoreServiceModule;
|
||||
|
@ -33,16 +36,21 @@ import google.registry.util.SystemClock.SystemClockModule;
|
|||
modules = {
|
||||
ConfigModule.class,
|
||||
DatastoreServiceModule.class,
|
||||
CloudDnsModule.class,
|
||||
DnsUpdateWriterModule.class,
|
||||
Jackson2Module.class,
|
||||
KeyModule.class,
|
||||
RegistryToolModule.class,
|
||||
SystemClockModule.class,
|
||||
URLFetchServiceModule.class,
|
||||
VoidDnsWriterModule.class,
|
||||
VoidKeyringModule.class,
|
||||
})
|
||||
}
|
||||
)
|
||||
interface RegistryToolComponent {
|
||||
void inject(CreateAnchorTenantCommand command);
|
||||
void inject(CreateContactCommand command);
|
||||
void inject(CreateTldCommand command);
|
||||
void inject(EncryptEscrowDepositCommand command);
|
||||
void inject(GenerateApplicationsReportCommand command);
|
||||
void inject(GenerateDnsReportCommand command);
|
||||
|
@ -53,6 +61,7 @@ interface RegistryToolComponent {
|
|||
void inject(SendEscrowReportToIcannCommand command);
|
||||
void inject(SetupOteCommand command);
|
||||
void inject(UpdateCursorsCommand command);
|
||||
void inject(UpdateTldCommand command);
|
||||
void inject(ValidateEscrowDepositCommand command);
|
||||
void inject(WhoisQueryCommand command);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue