hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: Workaround for intermittent IllegalArgumentException: host parameter is null
Date Sat, 10 Jan 2009 13:22:51 GMT
John Kalucki wrote:
> I have a multi-threaded stress test that, when under heavy load concurrently
> opening many HttpClient connections, intermittently receives
> an IllegalArgumentException with the following stack trace:
> Exception in thread "pool-3-thread-24" java.lang.IllegalArgumentException:
> host parameter is null
> at
> org.apache.commons.httpclient.HttpConnection.<init>(HttpConnection.java:206)
> at
> org.apache.commons.httpclient.HttpConnection.<init>(HttpConnection.java:155)
> at
> org.apache.commons.httpclient.SimpleHttpConnectionManager.getConnectionWithTimeout(SimpleHttpConnectionManager.java:175)
> at
> org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:153)
> at
> org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
> at
> org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323)
> 
> 
> Again- only intermittently under heavy connect load. There appears some sort
> of timing-related error in HttpClient. Perhaps around setting up the
> following chain in HttpMethodDirector.executeMethod, line 134
> 
>         // Link all parameter collections to form the hierarchy:
>         // Global -> HttpClient -> HostConfiguration -> HttpMethod
>         this.hostConfiguration.getParams().setDefaults(this.params);
>         method.getParams().setDefaults(this.hostConfiguration.getParams());
> 
> Possibly the params management is not fully thread-safe, or, the OS, on
> occasion, doesn't resolve the hostname quickly enough. In any case, the
> workaround I've found for this is to explicitly set the HostConfiguration
> before creating the GetMethod:
> 
>       val manager = new SimpleHttpConnectionManager(true)
>       val client = new HttpClient(manager)
> 
>       // Attempt to work around NTE in HttpConnection.java:206
>       val hostConfiguration = new HostConfiguration()
>       hostConfiguration.setHost(host, port)
>       client.setHostConfiguration(hostConfiguration)
> 
>       val getter = new GetMethod(url)
> 
> So far this has eliminated this intermittent failure.
> 
> -John Kalucki
> 

Hi John

This sounds like a race condition or synchronization issue to me. What 
version of HttpClient are you using? Could you please try to reproduce 
the problem with a test case, which ideally should not be dependent on 
your local environment.

Oleg


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


Mime
View raw message