Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 311389

Summary: [Net] NPE when using proxy definitions without host
Product: [Eclipse Project] Platform Reporter: Tom Hofmann <eclipse>
Component: TeamAssignee: Platform Team Inbox <platform-team-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: Szymon.Brandys, wojciech.galanciak
Version: 3.5.1   
Target Milestone: ---   
Hardware: PC   
OS: Windows Vista   
Whiteboard: stalebug
Attachments:
Description Flags
AbstractProxyProvider.java.diff none

Description Tom Hofmann CLA 2010-05-03 12:00:39 EDT
3.5.1, erroneous code is still in place in 3.6M7

- open Window > Prefs, General > Network
- have some manual proxy entries with an empty hostname
- choose 'native' proxy settings (manual settings still show up, but not checked)

- open the CVS Repositories view and try to open a repository

-> boom, see exception below

URI::getHost may return null, but AbstractProxyProvider::select does not guard against this. Will attach a patch.

java.lang.NullPointerException
    at org.eclipse.core.internal.net.AbstractProxyProvider.select(AbstractProxyProvider.java:37)
    at org.eclipse.core.internal.net.ProxyManager.getProxyDataForHost(ProxyManager.java:365)
    at org.eclipse.jsch.internal.core.Utils.getProxyData(Utils.java:111)
    at org.eclipse.jsch.internal.core.Utils.getProxyForHost(Utils.java:133)
    at org.eclipse.jsch.internal.core.Utils.setProxy(Utils.java:87)
    at org.eclipse.jsch.internal.core.Utils.createSession(Utils.java:78)
    at org.eclipse.jsch.internal.core.JSchProvider.createSession(JSchProvider.java:48)
    at org.eclipse.jsch.internal.core.JSchProvider.createSession(JSchProvider.java:56)
    at org.eclipse.team.internal.ccvs.ssh2.JSchSession.createSession(JSchSession.java:106)
[...]
Comment 1 Tom Hofmann CLA 2010-05-03 12:02:58 EDT
Created attachment 166801 [details]
AbstractProxyProvider.java.diff

Patch against AbstractProxyProvider.java R1.5
Comment 2 Wojciech Galanciak CLA 2010-08-24 11:46:57 EDT
I cannot reproduce this issue in Eclipse 3.6. In line 37 in AbstractProxyProvider is:
if (host.equals(nonProxyHosts[npIndex])) {

nonProxyHosts array cannot be null (but it can be empty). In this case only host should be null but host in this case means host of CVS repository. It is not related to proxy host in preferences. The stacktrace is similar to that from bug 293078.

Do you have any native proxy set and at least one bypass when you set native proxy provider in preferences?
Comment 3 Tom Hofmann CLA 2010-08-25 05:51:24 EDT
This may well be a dup of 2903078 - as for your analysis, all I can say that in my case, host (yes, this is the CVS host) was null, not the array, hence the NPE.

Given the logic to construct the URI in ProxyManager.getProxyDataForHost(String, String) and ProxyManager.tryGetURI(String), there seems to be no guarantee that the produced URI has a non-null host in all cases. So it would certainly make sense to guard against host being null, either as proposed by my patch or by adding a null check for host.
Comment 4 Wojciech Galanciak CLA 2010-10-06 06:38:07 EDT
Does your repository host name contain underscore (e.g. my_cvsrepo)?
Comment 5 Eclipse Webmaster CLA 2019-09-06 16:03:26 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.
Comment 6 Eclipse Genie CLA 2022-02-01 20:34:51 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.