Deprecated: org.apache.http.conn.scheme.scheme is deprecated

空扰寡人 提交于 2020-01-25 06:17:19

问题


I have this Codesnippet:

schemeRegistry.register(new Scheme("https", factory, 443));    

It says that the constructor for Scheme is deprecated, but I honestly didn't really understand which new method to use instead. Can someone show me a brief example on how to use it properly?

the complete Code in which it is used looks like this:

        org.apache.http.conn.ssl.SSLSocketFactory factory = new org.apache.http.conn.ssl.SSLSocketFactory(clientStore, p12Password, trustStore);
        SchemeRegistry schemeRegistry = new SchemeRegistry();
        schemeRegistry.register(new Scheme("https", factory2, 443));

        DefaultHttpClient httpClient = new DefaultHttpClient(new ThreadSafeClientConnManager(httpParams,schemeRegistry), httpParams);

Yes, the "new ThreadSafeClientConnManager(httpParams,schemeRegistry)" is also deprecated and I may open another Question for it, but it would be good to get started with the Scheme thing, to fix everything step by step.

Regards and thanks for answers PS: First Question here, I have been a silent reader most of the time, I of course look forward to advices on how to ask questions in the next time, still don't be too harsh please.


回答1:


As stated in the documentation, you should use this constructor instead:

Scheme(String name, int port, SchemeSocketFactory factory)


来源:https://stackoverflow.com/questions/21286181/deprecated-org-apache-http-conn-scheme-scheme-is-deprecated

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!