openrewrite / openrewrite/rewrite-apache
Migrate HttpClientBuilder.setSSLSocketFactory
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 6
- Forks
- 19
- Avg merge
- 56m
- Merged PRs (30d)
- 3
Description
What problem are you trying to solve?
In httpclient 5, setSSLSocketFactory is not available on the HttpClientBuilder anymore (also see this SO question with 35k views as of writing).
Instead the method is available on the HttpClientConnectionManager which can then be set on the builder HttpClientBuilder.setConnectionManager.
What precondition(s) should be checked before applying this recipe?
PoolingHttpClientConnectionManagerBuilder.setSSLSocketFactory is deprecated in httpclient5, so a version check may be needed in the future
Describe the situation before applying the recipe
class A {
void foo(String bar) {
SSLConnectionSocketFactory sslSocketFactory = new SSLConnectionSocketFactory(null);
CloseableHttpClient httpClient = HttpClientBuilder
.create()
.setSSLSocketFactory(sslSocketFactory)
.build();
}
}
Describe the situation after applying the recipe
class A {
void foo(String bar) {
SSLConnectionSocketFactory sslSocketFactory = new SSLConnectionSocketFactory(null);
HttpClientConnectionManager connectionManager = PoolingHttpClientConnectionManagerBuilder
.create()
.setSSLSocketFactory(sslSocketFactory)
.build();
CloseableHttpClient httpClient = HttpClientBuilder
.create()
.setConnectionManager(connectionManager)
.build();
}
}
Are you interested in contributing this recipe to OpenRewrite?
no
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the issue's before-and-after Java examples and confirm the HttpClient 5 APIs involved: HttpClientBuilder, HttpClientConnectionManager, and PoolingHttpClientConnectionManagerBuilder. No repository files or tests are named, so locate the existing recipe patterns and test conventions first; done means the shown builder migration is applied with the appropriate version precondition.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100