Nuria has submitted this change and it was merged. Change subject: Clean up IpUtil trusted proxy initialization ......................................................................
Clean up IpUtil trusted proxy initialization Remove unnecessary string trimming and runtime exception handling during IpUtil construction. This change mirrors updates requested during code review for Ib935849 which originally copied the trusted proxies initialization loop. Change-Id: I3dcd14f0d48a7ae18c3e15eef85151ca02b5d7ca --- M refinery-core/src/main/java/org/wikimedia/analytics/refinery/core/IpUtil.java 1 file changed, 3 insertions(+), 17 deletions(-) Approvals: Nuria: Verified; Looks good to me, approved jenkins-bot: Verified diff --git a/refinery-core/src/main/java/org/wikimedia/analytics/refinery/core/IpUtil.java b/refinery-core/src/main/java/org/wikimedia/analytics/refinery/core/IpUtil.java index 50b40b3..1e76b8f 100644 --- a/refinery-core/src/main/java/org/wikimedia/analytics/refinery/core/IpUtil.java +++ b/refinery-core/src/main/java/org/wikimedia/analytics/refinery/core/IpUtil.java @@ -98,23 +98,9 @@ trustedProxiesCache = new HashSet<IpAddressMatcher>(); labsSubnetsCache = new HashSet<IpAddressMatcher>(); - for (String proxyIp : trustedProxies) { - // We directly trim proxyIp here instead of using sanitizeIp() as - // it uses InetAddressValidator that fails for proxy address in - // CIDR notation - String trimmedProxyIp = proxyIp.trim(); - try { - IpAddressMatcher matcher = new IpAddressMatcher(trimmedProxyIp); - trustedProxiesCache.add(matcher); - } catch (IllegalArgumentException e) { - // Invalid entry in trustedProxies list - // In this case, the user did not pass any argument to us and - // hence throwing an IllegalArgumentException would be confusing - // Wrap and throw it as a RuntimeException - throw new RuntimeException("Invalid entry '" + proxyIp + "' " - + "found in the default trusted proxies list", e); - } - + for (String trustedProxy: trustedProxies) { + IpAddressMatcher matcher = new IpAddressMatcher(trustedProxy); + trustedProxiesCache.add(matcher); } for (String labsSubnet: labsSubnets) { -- To view, visit https://gerrit.wikimedia.org/r/253793 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I3dcd14f0d48a7ae18c3e15eef85151ca02b5d7ca Gerrit-PatchSet: 1 Gerrit-Project: analytics/refinery/source Gerrit-Branch: master Gerrit-Owner: BryanDavis <bda...@wikimedia.org> Gerrit-Reviewer: Hashar <has...@free.fr> Gerrit-Reviewer: Joal <j...@wikimedia.org> Gerrit-Reviewer: Nuria <nu...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits