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

Siqi Li commented on HTTPCLIENT-2059:
-------------------------------------

[~michael-o]

Here it is 

Exception in thread "main" java.lang.NullPointerException: HTTP context must 
not be null

Exception in thread "main" java.lang.NullPointerException: HTTP context must 
not be null

at org.apache.hc.core5.util.Args.NullPointerException(Args.java:102)

at org.apache.hc.core5.util.Args.notNull(Args.java:151)

at 
org.apache.hc.client5.http.protocol.HttpClientContext.adapt(HttpClientContext.java:134)

at 
org.apache.hc.client5.http.impl.async.MinimalHttpAsyncClient.execute(MinimalHttpAsyncClient.java:251)

at 
org.apache.hc.client5.http.impl.async.AbstractMinimalHttpAsyncClientBase.doExecute(AbstractMinimalHttpAsyncClientBase.java:64)

at 
org.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient.execute(CloseableHttpAsyncClient.java:98)

at foo.Foo.main(Foo.java:14)

 

 

> MinimalHttpAsyncClient does not allow null HttpContext
> ------------------------------------------------------
>
>                 Key: HTTPCLIENT-2059
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-2059
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpClient (async)
>    Affects Versions: 5.0
>            Reporter: Siqi Li
>            Priority: Minor
>
> In HttpAsyncClient.execute, the Javadoc says:
> {code:java}
> @param context HTTP context. Optional and may be {@code null}.{code}
> However, the following code will cause a NullPointerException because the 
> input HttpContext is null:
> {code:java}
>   public static void main(String[] args) throws Exception {
>     try (MinimalHttpAsyncClient client = HttpAsyncClients.createMinimal()) {
>       client.start();
>       
> client.execute(SimpleRequestProducer.create(SimpleHttpRequests.get("https://example.com";)),
>           SimpleResponseConsumer.create(), null, null, null).get();
>     }
>   }{code}
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to