mirror of
https://github.com/google/nomulus
synced 2026-09-04 23:27:11 +00:00
Extract multiple commit prevention in DNS writers into a base class
This still retains the DnsWriter interface itself for better integration with Dagger and to preserve the option of having a DNS writer that does not have this requirement (e.g. because it is idempotent). This also makes the commit check thread-safe, which is a nice-to-have. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=168451114
This commit is contained in:
@@ -14,8 +14,6 @@
|
||||
|
||||
package google.registry.dns.writer;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
@@ -27,7 +25,7 @@ import javax.inject.Inject;
|
||||
*
|
||||
* <p>All this class does is write its displeasure to the logs.
|
||||
*/
|
||||
public final class VoidDnsWriter implements DnsWriter {
|
||||
public final class VoidDnsWriter extends BaseDnsWriter {
|
||||
|
||||
/**
|
||||
* The name of the pricing engine, as used in {@code Registry.dnsWriter}. Remember to change
|
||||
@@ -37,8 +35,6 @@ public final class VoidDnsWriter implements DnsWriter {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(VoidDnsWriter.class.getName());
|
||||
|
||||
private boolean committed = false;
|
||||
|
||||
private final Set<String> names = new HashSet<>();
|
||||
|
||||
@Inject
|
||||
@@ -55,10 +51,7 @@ public final class VoidDnsWriter implements DnsWriter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commit() {
|
||||
checkState(!committed, "commit() has already been called");
|
||||
committed = true;
|
||||
|
||||
protected void commitUnchecked() {
|
||||
logger.warning("Ignoring DNS zone updates! No DnsWriterFactory implementation specified!\n"
|
||||
+ Joiner.on('\n').join(names));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user