How to get ConnectionConfig from PoolingHttpClientConnectionManager

21 views Asked by At

I see in https://hc.apache.org/httpcomponents-client-5.2.x/current/httpclient5/apidocs/org/apache/hc/client5/http/impl/io/PoolingHttpClientConnectionManager.html, getValidateAfterInactivity() and getDefaultSocketConfig() are deprecated and replaced with setter methods. Is this correct or it is a bug? What is alternate method to retrieve this.

This is my below code

PoolingHttpClientConnectionManager connMgr = null;
    SSLContext sslContext;
        Registry<ConnectionSocketFactory> socketFactoryRegistry = null;
            try {
                sslContext = new SSLContextBuilder()
                        .loadTrustMaterial(null, (certificate, authType) -> true).build();
                socketFactoryRegistry =
                        RegistryBuilder.<ConnectionSocketFactory>create()
                                .register("http", new PlainConnectionSocketFactory())
                                .register("https", new SSLConnectionSocketFactory(sslContext,
                                        customHostNameVerifier))
                                .build();
                connMgr = new PoolingHttpClientConnectionManager(
                        socketFactoryRegistry,null,
                        null,TimeValue.of(10, TimeUnit.MINUTES),null,null,null);
            } catch (Exception e) {
                logger.error("Exception while generating socket factory." + e);
            }
         connMgr.setMaxTotal(connectionObject.getMaxTotal());
         connMgr.setDefaultMaxPerRoute(connectionObject.getDefaultMaxPerRoute());
         connMgr.setDefaultConnectionConfig(ConnectionConfig.custom()
                .setValidateAfterInactivity(100, TimeUnit.MILLISECONDS)
                .build());

I am trying to set vales like this. But how do I retrieve values from PoolingHttpClientConnectionManager. Mainly I am looking to get the value for getValidateAfterInactivity() and getDefaultSocketConfig() which are deprecated.

Could someone help to get this data?

0

There are 0 answers