Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RESTClient use deprecated API org.apache.http.impl.client.DefaultHttpClient #70

Open
ArtyomKravchenko opened this issue Feb 9, 2017 · 2 comments

Comments

@ArtyomKravchenko
Copy link

groovyx.net.http.RESTClient (inherited of groovyx.net.http.HTTPBuilder) uses deprecated API from
org.apache.httpcomponents:httpclient lib - see HTTPBuilder.createClient(HttpParams param) method. It creates DefaultHttpClient which are deprecated in latest httpclient releases.

Such API (like DefaultHttpClient and other) has a several bugs related to SSL connection like:
https://issues.apache.org/jira/browse/HTTPCLIENT-1726
JDK issue also applicable for httpclient I think:
https://bugs.openjdk.java.net/browse/JDK-8144566

I believe that issue #68 SSL/TLS authentication has the same cause.

In my testing I got exception:
Caused by: javax.net.ssl.SSLException: Received fatal alert: internal_error
at sun.security.ssl.Alerts.getSSLException(Alerts.java:208)
at sun.security.ssl.Alerts.getSSLException(Alerts.java:154)
at sun.security.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:2023)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1125)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1375)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1403)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1387)
at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:543)
at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:409)
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:177)
at org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:304)
at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:611)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:446)
at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:882)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:71)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:220)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:164)
at groovyx.net.http.HTTPBuilder.doRequest(HTTPBuilder.java:515)
at groovyx.net.http.HTTPBuilder.doRequest(HTTPBuilder.java:434)
at groovyx.net.http.HTTPBuilder.request(HTTPBuilder.java:383)
at groovyx.net.http.HTTPBuilder$request.call(Unknown Source)

I have rewritten single HTTPBuilder.createClient(HttpParams param) method for mine anonymous RESTClient instance: use org.apache.http.impl.client.HttpClientBuilder instead of deprecated DefaultHttpClient (as proposed in httpclient docs) and it solve the problem.

Dear developers, It will be fine to update httpclient dependency inside http-builder and use actual api instead of deprecated one.

@kenwdelong
Copy link

@ArtyomKravchenko Maybe you could create a pull request so we could all benefit from your changes?

@joasgarcia
Copy link

@ArtyomKravchenko It would be useful if you share your code using org.apache.http.impl.client.HttpClientBuilder instead o DefaultHttpClient, because I got this same problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants