From: Duarte Meneses Date: Thu, 3 Jun 2021 13:45:20 +0000 (-0500) Subject: SONAR-14870 DNS cache never expires causing PR decoration to fail X-Git-Tag: 8.9.1.44547~3 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ece6625a2c6f16048078f1497fe13c4c43bd5368;p=sonarqube.git SONAR-14870 DNS cache never expires causing PR decoration to fail --- diff --git a/server/sonar-process/src/main/java/org/sonar/process/SecurityManagement.java b/server/sonar-process/src/main/java/org/sonar/process/SecurityManagement.java index 7a2d32f4fc5..137e0a539c6 100644 --- a/server/sonar-process/src/main/java/org/sonar/process/SecurityManagement.java +++ b/server/sonar-process/src/main/java/org/sonar/process/SecurityManagement.java @@ -25,12 +25,15 @@ import java.security.PermissionCollection; import java.security.Permissions; import java.security.Policy; import java.security.ProtectionDomain; +import java.security.Security; import java.security.SecurityPermission; import java.util.Arrays; import java.util.HashSet; import java.util.Set; public class SecurityManagement { + private static final String CACHE_TTL_KEY = "networkaddress.cache.ttl"; + private SecurityManagement() { // static only } @@ -39,6 +42,10 @@ public class SecurityManagement { SecurityManager sm = new SecurityManager(); Policy.setPolicy(new CustomPolicy()); System.setSecurityManager(sm); + // SONAR-14870 By default, with a security manager installed, the DNS cache never times out. See InetAddressCachePolicy. + if (Security.getProperty(CACHE_TTL_KEY) == null) { + Security.setProperty(CACHE_TTL_KEY, "30"); + } } static class CustomPolicy extends Policy {