You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Oleg Kalnichevski (JIRA)" <ji...@apache.org> on 2019/01/09 14:15:00 UTC

[jira] [Commented] (HTTPCLIENT-1959) Proxy support not working in 5.0 (IllegalArgumentException: Inet address must not be null)

    [ https://issues.apache.org/jira/browse/HTTPCLIENT-1959?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16738286#comment-16738286 ] 

Oleg Kalnichevski commented on HTTPCLIENT-1959:
-----------------------------------------------

[~matf] Feel free to raise a PR at GitHub if you have a fix to propose.

Oleg

> Proxy support not working in 5.0 (IllegalArgumentException: Inet address must not be null)
> ------------------------------------------------------------------------------------------
>
>                 Key: HTTPCLIENT-1959
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1959
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpClient (classic)
>    Affects Versions: 5.0 Beta3
>            Reporter: Matthias Fritschi
>            Priority: Major
>             Fix For: 5.0 Beta4
>
>         Attachments: ProxyTest.java
>
>
> When a proxy host and port are specified via the JVM properties https.proxyHost / https.proxyPort, an IllegalArgumentException is thrown on any HTTP request (see stacktrace below)
> h2. Steps to reproduce
> 1) Specify a proxy via https.proxyHost/https.proxyPort JVM properties
> 2) Execute for example a HTTP GET via httpClient.execute(...)
> 3) java.lang.IllegalArgumentException: Inet address must not be null is thrown (see stacktrace below)
> h2. Analysis
> The sun.net.spi.DefaultProxySelector deliberately does not resolve the proxy's address, see http://hg.openjdk.java.net/jdk10/jdk10/jdk/file/9b8c96f96a0f/src/share/classes/sun/net/spi/DefaultProxySelector.java#l294. 
> SystemDefaultRoutePlanner in httpclient5 assumes the address has been resolved, see https://github.com/apache/httpcomponents-client/blob/5.0-beta3/httpclient5/src/main/java/org/apache/hc/client5/http/impl/routing/SystemDefaultRoutePlanner.java#L100
> See the attached reproducer test or the code snippet below.
> h2. Versions used
> org.apache.httpcomponents.client5:httpclient5:5.0-beta3
> Oracle JDK 10.0.2 on OSX and Windows
> {code}
> java.lang.IllegalArgumentException: Inet address must not be null
> 	at org.apache.hc.core5.util.Args.illegalArgumentExceptionNotNull(Args.java:101)
> 	at org.apache.hc.core5.util.Args.notNull(Args.java:150)
> 	at org.apache.hc.core5.http.HttpHost.<init>(HttpHost.java:286)
> 	at org.apache.hc.client5.http.impl.routing.SystemDefaultRoutePlanner.determineProxy(SystemDefaultRoutePlanner.java:100)
> 	at org.apache.hc.client5.http.impl.routing.DefaultRoutePlanner.determineRoute(DefaultRoutePlanner.java:71)
> 	at org.apache.hc.client5.http.impl.classic.InternalHttpClient.determineRoute(InternalHttpClient.java:122)
> 	at org.apache.hc.client5.http.impl.classic.InternalHttpClient.doExecute(InternalHttpClient.java:166)
> 	at org.apache.hc.client5.http.impl.classic.CloseableHttpClient.execute(CloseableHttpClient.java:77)
> 	at org.apache.hc.client5.http.impl.classic.CloseableHttpClient.execute(CloseableHttpClient.java:102)
> {code}
> {code}
> System.setProperty("https.proxyHost", "<TODO: Your Proxy Host Here>");
> System.setProperty("https.proxyPort", "8080");
> CloseableHttpClient httpClient = HttpClients.createSystem();
> HttpGet httpGet = new HttpGet("https://www.google.com/");
> CloseableHttpResponse response = httpClient.execute(httpGet);
> System.out.println(response.getCode());
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org