Skip to content

Commit a98a7f8

Browse files
committed
Don't use .contextSensitive() where it's not needed
1 parent 08a4322 commit a98a7f8

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

src/main/java/org/openrewrite/apache/httpclient5/MigrateSSLConnectionSocketFactory.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,12 @@ public J.VariableDeclarations visitVariableDeclarations(J.VariableDeclarations m
9595
maybeAddImport(TLS_SOCKET_STRATEGY);
9696
maybeAddImport(DEFAULT_TLS_SOCKET_STRATEGY);
9797
return JavaTemplate.builder(code)
98-
.contextSensitive()
9998
.javaParser(JavaParser.fromJavaVersion()
10099
.classpathFromResources(ctx, "httpclient5", "httpcore5"))
101100
.imports(TLS_SOCKET_STRATEGY,
102101
DEFAULT_TLS_SOCKET_STRATEGY)
103102
.build()
104-
.apply(getCursor(), vd.getCoordinates().replace(), new Object[]{newClass.getArguments().get(0)});
103+
.apply(getCursor(), vd.getCoordinates().replace(), newClass.getArguments().get(0));
105104
}
106105
}
107106

@@ -160,14 +159,13 @@ public J.MethodDeclaration visitMethodDeclaration(J.MethodDeclaration method, Ex
160159

161160
if (!connectionManagerExists) {
162161
J.Identifier tlsStrategyIdentifier = tlsStrategyDecl.getVariables().get(0).getName();
163-
final String httpClientConnectionManagerCode = "HttpClientConnectionManager cm = PoolingHttpClientConnectionManagerBuilder.create()" +
162+
String httpClientConnectionManagerCode = "HttpClientConnectionManager cm = PoolingHttpClientConnectionManagerBuilder.create()" +
164163
".setTlsSocketStrategy(#{any(org.apache.hc.client5.http.ssl.TlsSocketStrategy)}).build();";
165164

166165
maybeAddImport(HTTP_CLIENT_CONNECTION_MANAGER);
167166
maybeAddImport(POOLING_HTTP_CLIENT_CONNECTION_MANAGER_BUILDER);
168167

169168
return JavaTemplate.builder(httpClientConnectionManagerCode)
170-
.contextSensitive()
171169
.javaParser(JavaParser.fromJavaVersion()
172170
.classpathFromResources(ctx, "httpclient5", "httpcore5"))
173171
.imports(HTTP_CLIENT_CONNECTION_MANAGER,

0 commit comments

Comments
 (0)