Skip to content

Commit 9ab5f86

Browse files
authored
Improve MigrateDefaultHttpClient documentation (#493)
Signed-off-by: Jonathan Leitschuh <[email protected]>
1 parent 078ef37 commit 9ab5f86

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/main/java/org/openrewrite/java/apache/httpclient4/MigrateDefaultHttpClient.java

+16-3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
import org.openrewrite.java.search.UsesType;
2424
import org.openrewrite.java.tree.J;
2525

26+
import java.util.Collections;
27+
import java.util.Set;
28+
2629
public class MigrateDefaultHttpClient extends Recipe {
2730
@Override
2831
public String getDisplayName() {
@@ -31,8 +34,18 @@ public String getDisplayName() {
3134

3235
@Override
3336
public String getDescription() {
34-
return "Since DefaultHttpClient is deprecated, we need to change it to the CloseableHttpClient. " +
35-
"It only covers the default scenario with no custom HttpParams or ConnectionManager.";
37+
return "Since `DefaultHttpClient` is deprecated, we need to change it to the `CloseableHttpClient`. " +
38+
"It only covers the default scenario with no custom `HttpParams` or `ConnectionManager`.\n\n" +
39+
"Of note: the `DefaultHttpClient` [does not support TLS 1.2](https://find-sec-bugs.github.io/bugs.htm#DEFAULT_HTTP_CLIENT).\n" +
40+
"\n" +
41+
"References:\n" +
42+
" - [Find Sec Bugs](https://find-sec-bugs.github.io/bugs.htm#DEFAULT_HTTP_CLIENT)" +
43+
" - [IBM Support Pages](https://www.ibm.com/support/pages/im-using-apache-httpclient-make-outbound-call-my-web-application-running-websphere-application-server-traditional-and-im-getting-ssl-handshake-error-how-can-i-debug)";
44+
}
45+
46+
@Override
47+
public Set<String> getTags() {
48+
return Collections.singleton("CWE-326");
3649
}
3750

3851
@Override
@@ -46,7 +59,7 @@ public TreeVisitor<?, ExecutionContext> getVisitor() {
4659

4760
@Override
4861
public J visitNewClass(J.NewClass newClass, ExecutionContext ctx) {
49-
if (noArgsMatcher.matches(newClass.getConstructorType())) {
62+
if (noArgsMatcher.matches(newClass)) {
5063
maybeAddImport("org.apache.http.impl.client.HttpClients");
5164
doAfterVisit(new ChangeType(
5265
"org.apache.http.impl.client.DefaultHttpClient",

0 commit comments

Comments
 (0)