Skip to content

Commit

Permalink
use Apache HttpClient 5.4.x (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
sullis authored Nov 15, 2024
1 parent f278b86 commit 72c0877
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ recipeList:
oldArtifactId: httpclient
newGroupId: org.apache.httpcomponents.client5
newArtifactId: httpclient5
newVersion: 5.3.x
newVersion: 5.4.x
- org.openrewrite.java.dependencies.ChangeDependency:
oldGroupId: org.apache.httpcomponents
oldArtifactId: httpcore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ void migrateDependencies() {
</dependencies>
</project>
""", spec -> spec.after(pom -> {
Matcher version = Pattern.compile("5\\.3\\.\\d+").matcher(pom);
assertThat(version.find()).describedAs("Expected 5.3.x in %s", pom).isTrue();
Matcher version = Pattern.compile("5\\.4\\.\\d+").matcher(pom);
assertThat(version.find()).describedAs("Expected 5.4.x in %s", pom).isTrue();
return """
<project>
<modelVersion>4.0.0</modelVersion>
Expand Down Expand Up @@ -134,7 +134,7 @@ void method() {
.setConnectionRequestTimeout(300)
.setConnectTimeout(connectTimeout)
.setSocketTimeout(connectTimeout * 10);
long linger = 420;
SocketConfig.custom()
.setSoTimeout(1000)
Expand All @@ -144,7 +144,7 @@ void method() {
""", """
import org.apache.hc.client5.http.config.RequestConfig;
import org.apache.hc.core5.http.io.SocketConfig;
import java.util.concurrent.TimeUnit;
class A {
Expand All @@ -154,7 +154,7 @@ void method() {
.setConnectionRequestTimeout(300, TimeUnit.MILLISECONDS)
.setConnectTimeout(connectTimeout, TimeUnit.MILLISECONDS)
.setResponseTimeout(connectTimeout * 10, TimeUnit.MILLISECONDS);
long linger = 420;
SocketConfig.custom()
.setSoTimeout(1000, TimeUnit.MILLISECONDS)
Expand All @@ -177,15 +177,15 @@ void removeStatusLineHttpResponse() {
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.ProtocolVersion;
import java.io.IOException;
class A {
void method() throws IOException {
HttpGet httpGet = new HttpGet("https://moderne.io");
CloseableHttpClient instance = HttpClientBuilder.create().build();
CloseableHttpResponse response = instance.execute(httpGet);
System.out.println("response.getStatusLine() :: " + response.getStatusLine());
int statusCode = response.getStatusLine().getStatusCode();
String reason = response.getStatusLine().getReasonPhrase();
Expand All @@ -201,15 +201,15 @@ void method() throws IOException {
import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
import org.apache.hc.core5.http.ProtocolVersion;
import org.apache.hc.core5.http.message.StatusLine;
import java.io.IOException;
class A {
void method() throws IOException {
HttpGet httpGet = new HttpGet("https://moderne.io");
CloseableHttpClient instance = HttpClientBuilder.create().build();
CloseableHttpResponse response = instance.execute(httpGet);
System.out.println("response.getStatusLine() :: " + new StatusLine(response));
int statusCode = response.getCode();
String reason = response.getReasonPhrase();
Expand Down

0 comments on commit 72c0877

Please sign in to comment.