From 4e74473d4b8cda94d15964d1f9a2ccf41ea3c919 Mon Sep 17 00:00:00 2001 From: Bhuvan Teja Date: Wed, 5 Nov 2025 16:53:18 -0800 Subject: [PATCH] Handled empty string passed for FORWARD_PROXY variables --- .../com/glean/proxy/ChainedProxyConfiguration.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/glean/proxy/ChainedProxyConfiguration.java b/src/main/java/com/glean/proxy/ChainedProxyConfiguration.java index 0d7d11e..13b8db5 100644 --- a/src/main/java/com/glean/proxy/ChainedProxyConfiguration.java +++ b/src/main/java/com/glean/proxy/ChainedProxyConfiguration.java @@ -15,15 +15,20 @@ public class ChainedProxyConfiguration { private static final Logger logger = Logger.getLogger(ChainedProxyConfiguration.class.getName()); public static ChainedProxyManager fromEnvironment() { - if (System.getenv("FORWARD_PROXY_HOST") == null || System.getenv("FORWARD_PROXY_PORT") == null || System.getenv("FORWARD_PROXY_DATA_SOURCE_HOSTS") == null) { + String forwardProxyHost = System.getenv("FORWARD_PROXY_HOST"); + String forwardProxyPort = System.getenv("FORWARD_PROXY_PORT"); + String dataSourceHostsEnv = System.getenv("FORWARD_PROXY_DATA_SOURCE_HOSTS"); + if (forwardProxyHost == null || forwardProxyHost.isEmpty() || + forwardProxyPort == null || forwardProxyPort.isEmpty() || + dataSourceHostsEnv == null || dataSourceHostsEnv.isEmpty()) { return (HttpRequest httpRequest, Queue chainedProxies, ClientDetails clientDetails) -> { chainedProxies.add(ChainedProxyAdapter.FALLBACK_TO_DIRECT_CONNECTION); }; } - InetSocketAddress forwardProxy = new InetSocketAddress(System.getenv("FORWARD_PROXY_HOST"), Integer.parseInt(System.getenv("FORWARD_PROXY_PORT"))); - Set dataSourceHosts = Set.of(System.getenv("FORWARD_PROXY_DATA_SOURCE_HOSTS").split(",")); + InetSocketAddress forwardProxy = new InetSocketAddress(forwardProxyHost, Integer.parseInt(forwardProxyPort)); + Set dataSourceHosts = Set.of(dataSourceHostsEnv.split(",")); ChainedProxyManager chainedProxyManager = (HttpRequest httpRequest, Queue chainedProxies,