You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Francois-Xavier Bonnet (JIRA)" <ji...@apache.org> on 2013/02/19 15:57:13 UTC

[jira] [Commented] (HTTPCLIENT-1324) CachingHttpClientBuilder.build() fails when asynchronousWorkersMax=0

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

Francois-Xavier Bonnet commented on HTTPCLIENT-1324:
----------------------------------------------------

Currently there are 2 ways to create the AsynchronousValidator
1) org.apache.http.impl.client.cache.CachingHttpClientBuilder.createAsynchronousRevalidator(CacheConfig) there is no check that asynchronousWorkersMax=0 but there is a call to addCloseable(revalidator);
2) org.apache.http.impl.client.cache.CachingExec.makeAsynchronousValidator(CacheConfig) it is checked that asynchronousWorkersMax>0 no  addCloseable(revalidator); so ExecutorService is never closed

In my opinion we should keep only 1) and add a check that asynchronousWorkersMax>0
                
> CachingHttpClientBuilder.build() fails when asynchronousWorkersMax=0
> --------------------------------------------------------------------
>
>                 Key: HTTPCLIENT-1324
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1324
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: Cache
>    Affects Versions: 4.3 Alpha1
>            Reporter: Francois-Xavier Bonnet
>            Priority: Minor
>
> The following code throws an Exception:
> CacheConfig cacheConfig = CacheConfig.custom().setAsynchronousWorkersMax(0).build();
> CachingHttpClientBuilder.create().setCacheConfig(cacheConfig).build();
> java.lang.IllegalArgumentException
> 	at java.util.concurrent.ThreadPoolExecutor.<init>(ThreadPoolExecutor.java:826)
> 	at java.util.concurrent.ThreadPoolExecutor.<init>(ThreadPoolExecutor.java:717)
> 	at org.apache.http.impl.client.cache.AsynchronousValidator.<init>(AsynchronousValidator.java:74)
> 	at org.apache.http.impl.client.cache.CachingHttpClientBuilder.createAsynchronousRevalidator(CachingHttpClientBuilder.java:106)
> 	at org.apache.http.impl.client.cache.CachingHttpClientBuilder.decorateMainExec(CachingHttpClientBuilder.java:100)
> 	at org.apache.http.impl.client.HttpClientBuilder.build(HttpClientBuilder.java:528)
> According to the javadoc of method org.apache.http.impl.client.cache.CacheConfig.Builder.setAsynchronousWorkersMax(int) "a value of 0 disables background revalidations"

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

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