diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/testing/LocalDnsHelper.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/testing/LocalDnsHelper.java index 984d58ef496b..9b253227bf10 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/testing/LocalDnsHelper.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/testing/LocalDnsHelper.java @@ -69,6 +69,8 @@ import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.ConcurrentNavigableMap; import java.util.concurrent.ConcurrentSkipListMap; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.atomic.AtomicReference; import java.util.logging.Level; import java.util.logging.Logger; @@ -106,8 +108,11 @@ public class LocalDnsHelper { private static final TreeSet FORBIDDEN = Sets.newTreeSet( ImmutableList.of("google.com.", "com.", "example.com.", "net.", "org.")); private static final Pattern ZONE_NAME_RE = Pattern.compile("[a-z][a-z0-9-]*"); + private static final ScheduledExecutorService EXECUTORS = + Executors.newScheduledThreadPool(4, Executors.defaultThreadFactory()); static { + try { BASE_CONTEXT = new URI(CONTEXT); } catch (URISyntaxException e) { @@ -746,6 +751,12 @@ Response createChange(String projectId, String zoneName, Change change, String.. private Thread invokeChange(final String projectId, final String zoneName, final String changeId) { if (delayChange > 0) { + EXECUTORS.scheduleWithFixedDelay(new Runnable() { + @Override + public void run() { + applyExistingChange(projectId, zoneName, changeId); + } + }, delayChange, ) Thread thread = new Thread() { @Override public void run() {