Bug 548962 - NPE in UnixProxyProvider when environment variable is empty
Summary: NPE in UnixProxyProvider when environment variable is empty
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Runtime (show other bugs)
Version: 4.12   Edit
Hardware: PC Mac OS X
: P3 normal with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: platform-runtime-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-07-04 03:50 EDT by Gunnar Wagenknecht CLA
Modified: 2021-04-07 15:49 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gunnar Wagenknecht CLA 2019-07-04 03:50:41 EDT
It looks like on some environments https_proxy could be empty *or* at least UnixProxyProvider.getEnv returns an empty string.

I think the best would be to enhance the check in line 156 to not just check for null but also for an empty string.


The message logged is:
Problem during accessing system variable: https_proxy

Together with the following stacktrace:

java.lang.NullPointerException: no host in 
	at java.util.Objects.requireNonNull(Objects.java:228)
	at org.eclipse.core.internal.net.proxy.unix.UnixProxyProvider.getSystemProxyInfo(UnixProxyProvider.java:163)
	at org.eclipse.core.internal.net.proxy.unix.UnixProxyProvider.select(UnixProxyProvider.java:66)
	at org.eclipse.core.internal.net.ProxyManager.getProxyDataForHost(ProxyManager.java:343)
	at org.eclipse.core.internal.net.ProxyManager.select(ProxyManager.java:431)
	at org.eclipse.egit.core.EclipseProxySelector.select(EclipseProxySelector.java:50)
	at com.microsoft.applicationinsights.core.dependencies.http.impl.conn.SystemDefaultRoutePlanner.determineProxy(SystemDefaultRoutePlanner.java:94)
	at com.microsoft.applicationinsights.core.dependencies.http.impl.conn.DefaultRoutePlanner.determineRoute(DefaultRoutePlanner.java:78)
	at com.microsoft.applicationinsights.core.dependencies.http.impl.client.InternalHttpClient.determineRoute(InternalHttpClient.java:125)
	at com.microsoft.applicationinsights.core.dependencies.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
	at com.microsoft.applicationinsights.core.dependencies.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
	at com.microsoft.applicationinsights.core.dependencies.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:108)
	at com.microsoft.applicationinsights.core.dependencies.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56)
	at com.microsoft.applicationinsights.internal.channel.common.ApacheSender43.sendPostRequest(ApacheSender43.java:75)
	at com.microsoft.applicationinsights.internal.channel.common.TransmissionNetworkOutput.send(TransmissionNetworkOutput.java:185)
	at com.microsoft.applicationinsights.internal.channel.common.ActiveTransmissionNetworkOutput$1.run(ActiveTransmissionNetworkOutput.java:79)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Comment 1 Annika Karjakina CLA 2021-04-07 15:49:35 EDT
It's not Mac OS X specific, we can also reproduce on SUSE Linux Enterprise Server 12 SP5 and on CentOS 7 with Eclipse 4.18 and 4.19. 
To reproduce, just add an empty "socks_proxy=" variable:
qaprague@qa-tools-s12c11:~> printenv |grep proxy
http_proxy=http://web-proxy.eu.softwaregrp.net:8080
ftp_proxy=http://web-proxy.eu.softwaregrp.net:8080
socks_proxy=
gopher_proxy=
https_proxy=http://web-proxy.eu.softwaregrp.net:8080
no_proxy=localhost,127.0.0.1,.localdomain