Skip to content

Commit

Permalink
Merge pull request #15458 from cdapio/develop-fix-ip-caching
Browse files Browse the repository at this point in the history
[CDAP-20781] fix issue where service ip is cached forever
  • Loading branch information
CuriousVini authored Nov 27, 2023
2 parents 054fde0 + abc76c1 commit 9ef153f
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.bridge.SLF4JBridgeHandler;
import sun.net.InetAddressCachePolicy;

/**
* A {@link TwillRunnable} for running a program through a {@link ProgramRunner}.
Expand Down Expand Up @@ -172,6 +173,16 @@ private void doInitialize(File programOptionFile) throws Exception {
controllerFuture = new CompletableFuture<>();
programCompletion = new CompletableFuture<>();

// Make sure InetAddressCachePolicy is not set to FOREVER.
// This is needed because if InetAddressCachePolicy is loaded after System#setSecurityManager() call,
// caching policy is set to FOREVER. With FOREVER, caching policy, this twill runnable will not be able to
// reach out to other services within the cluster as IP is cached forever.
// Look at CDAP-20781 for more information.
if (InetAddressCachePolicy.get() == InetAddressCachePolicy.FOREVER) {
LOG.warn("InetAddress cache policy is set to FOREVER. This will ips to be cached forever. "
+ "Ensure cache policy is not set to FOREVER.");
}

// Setup process wide settings
Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler());
System.setSecurityManager(new ProgramContainerSecurityManager(System.getSecurityManager()));
Expand Down

0 comments on commit 9ef153f

Please sign in to comment.