You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "liqiang.liu (Jira)" <ji...@apache.org> on 2023/01/11 12:31:00 UTC

[jira] [Updated] (HTTPCLIENT-2256) The CloseableHttpClient is shut down due to an java.lang.StackOverflowError exception

     [ https://issues.apache.org/jira/browse/HTTPCLIENT-2256?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

liqiang.liu updated HTTPCLIENT-2256:
------------------------------------
    Description: 
builded the  CloseableHttpClient  via  the code 
{code:java}
private static final CloseableHttpClient HttpClient = bulidClient();
private static CloseableHttpClient bulidClient() {
HttpClientBuilder httpClientBuilder = HttpClients.custom().setMaxConnTotal(1000).setMaxConnPerRoute(1000);
httpClientBuilder.setDefaultRequestConfig(RequestConfig.custom().setConnectionRequestTimeout(2000).setConnectTimeout(3000).setSocketTimeout(4000).build());
httpClientBuilder.setDefaultSocketConfig(SocketConfig.custom().setSoLinger(0).setSoKeepAlive(false).setTcpNoDelay(true).setSoTimeout(4000).build());
httpClientBuilder.setDefaultConnectionConfig(ConnectionConfig.custom().setBufferSize(8192).build());
httpClientBuilder.setRetryHandler(new DefaultHttpRequestRetryHandler(2, false));
return httpClientBuilder.setConnectionManagerShared(true).build();
} {code}
The HttpClient becomes unavailable when a  java.lang.StackOverflowError  occurs. Even if the jvm recovers.  I found out why:

class MainClientExec in the source code closes the connection pool when an StackOverflowError occurs, causing the client to fail to recover. 

 

!image-2023-01-11-20-25-17-784.png!

 

I expect it to keep working when something goes wrong

  was:
builded the  CloseableHttpClient  via  the code 

 

~private static final CloseableHttpClient HttpClient = bulidClient();~

~private static CloseableHttpClient bulidClient() {~
 ~HttpClientBuilder httpClientBuilder = HttpClients.custom().setMaxConnTotal(1000).setMaxConnPerRoute(1000);~
 ~httpClientBuilder.setDefaultRequestConfig(RequestConfig.custom().setConnectionRequestTimeout(2000).setConnectTimeout(3000).setSocketTimeout(4000).build());~
 ~httpClientBuilder.setDefaultSocketConfig(SocketConfig.custom().setSoLinger(0).setSoKeepAlive(false).setTcpNoDelay(true).setSoTimeout(4000).build());~
 ~httpClientBuilder.setDefaultConnectionConfig(ConnectionConfig.custom().setBufferSize(8192).build());~
 ~httpClientBuilder.setRetryHandler(new DefaultHttpRequestRetryHandler(2, false));~
 ~return httpClientBuilder.setConnectionManagerShared(true).build();~
~}~

 

The HttpClient becomes unavailable when a  java.lang.StackOverflowError  occurs. Even if the jvm recovers.  I found out why:

class MainClientExec in the source code closes the connection pool when an StackOverflowError occurs, causing the client to fail to recover. 

 

!image-2023-01-11-20-25-17-784.png!

 

I expect it to keep working when something goes wrong


> The CloseableHttpClient is shut down due to an java.lang.StackOverflowError exception
> -------------------------------------------------------------------------------------
>
>                 Key: HTTPCLIENT-2256
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-2256
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpClient (classic)
>    Affects Versions: 4.5.13
>            Reporter: liqiang.liu
>            Priority: Major
>         Attachments: image-2023-01-11-20-25-17-784.png
>
>
> builded the  CloseableHttpClient  via  the code 
> {code:java}
> private static final CloseableHttpClient HttpClient = bulidClient();
> private static CloseableHttpClient bulidClient() {
> HttpClientBuilder httpClientBuilder = HttpClients.custom().setMaxConnTotal(1000).setMaxConnPerRoute(1000);
> httpClientBuilder.setDefaultRequestConfig(RequestConfig.custom().setConnectionRequestTimeout(2000).setConnectTimeout(3000).setSocketTimeout(4000).build());
> httpClientBuilder.setDefaultSocketConfig(SocketConfig.custom().setSoLinger(0).setSoKeepAlive(false).setTcpNoDelay(true).setSoTimeout(4000).build());
> httpClientBuilder.setDefaultConnectionConfig(ConnectionConfig.custom().setBufferSize(8192).build());
> httpClientBuilder.setRetryHandler(new DefaultHttpRequestRetryHandler(2, false));
> return httpClientBuilder.setConnectionManagerShared(true).build();
> } {code}
> The HttpClient becomes unavailable when a  java.lang.StackOverflowError  occurs. Even if the jvm recovers.  I found out why:
> class MainClientExec in the source code closes the connection pool when an StackOverflowError occurs, causing the client to fail to recover. 
>  
> !image-2023-01-11-20-25-17-784.png!
>  
> I expect it to keep working when something goes wrong



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

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