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

Update okhttp to 4.9.2 #1281

Merged
merged 5 commits into from
Nov 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<spotbugs.version>4.4.2</spotbugs.version>
<spotbugs-maven-plugin.failOnError>true</spotbugs-maven-plugin.failOnError>
<hamcrest.version>2.2</hamcrest.version>
<okhttp3.version>4.4.1</okhttp3.version>
<okhttp3.version>4.9.2</okhttp3.version>
<okio.version>2.10.0</okio.version>
<!-- Using this as the minimum bar for code coverage. Adding methods without covering them will fail this. -->
<jacoco.coverage.target.bundle.method>0.70</jacoco.coverage.target.bundle.method>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import okhttp3.Cache;
import okhttp3.OkHttpClient;
import org.apache.commons.io.FileUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.kohsuke.github.AbstractGitHubWireMockTest;
Expand Down Expand Up @@ -67,6 +68,7 @@ public OkHttpConnectorTest() {
private static int maxAgeNoneHitCount = 11;

private GHRateLimit rateLimitBefore;
private Cache cache = null;

@Override
protected WireMockConfiguration getWireMockOptions() {
Expand All @@ -88,6 +90,13 @@ public void setupRepo() throws Exception {
}
}

@After
public void deleteCache() throws IOException {
if (cache != null) {
cache.delete();
}
}

@Test
public void DefaultConnector() throws Exception {

Expand Down Expand Up @@ -120,7 +129,6 @@ public void OkHttpConnector_NoCache() throws Exception {

checkRequestAndLimit(okhttpNetworkRequestCount, okhttpRateLimitUsed);

Cache cache = client.cache();
assertThat("Cache", cache, is(nullValue()));
}

Expand All @@ -147,8 +155,6 @@ public void OkHttpConnector_Cache_MaxAgeNone() throws Exception {

checkRequestAndLimit(maxAgeNoneNetworkRequestCount, maxAgeNoneRateLimitUsed);

Cache cache = client.cache();

// NOTE: this is actually bad.
// This elevated hit count is the stale requests returning bad data took longer to detect a change.
assertThat("getHitCount", cache.hitCount(), is(maxAgeNoneHitCount));
Expand Down Expand Up @@ -176,7 +182,6 @@ public void OkHttpConnector_Cache_MaxAge_Three() throws Exception {

checkRequestAndLimit(maxAgeThreeNetworkRequestCount, maxAgeThreeRateLimitUsed);

Cache cache = client.cache();
assertThat("getHitCount", cache.hitCount(), is(maxAgeThreeHitCount));
}

Expand All @@ -202,7 +207,6 @@ public void OkHttpConnector_Cache_MaxAgeDefault_Zero() throws Exception {

checkRequestAndLimit(maxAgeZeroNetworkRequestCount, maxAgeZeroRateLimitUsed);

Cache cache = client.cache();
assertThat("getHitCount", cache.hitCount(), is(maxAgeZeroHitCount));
}

Expand All @@ -228,7 +232,7 @@ private OkHttpClient createClient(boolean useCache) throws IOException {
File cacheDir = new File("target/cache/" + baseFilesClassPath + "/" + mockGitHub.getMethodName());
cacheDir.mkdirs();
FileUtils.cleanDirectory(cacheDir);
Cache cache = new Cache(cacheDir, 100 * 1024L * 1024L);
cache = new Cache(cacheDir, 100 * 1024L * 1024L);

builder.cache(cache);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
"name": "repos_hub4j-test-org_github-api",
"request": {
"url": "/repos/hub4j-test-org/github-api",
"method": "GET"
"method": "GET",
"headers": {
"If-None-Match": {
"absent" : true
}
}
},
"response": {
"status": 200,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"method": "GET",
"headers": {
"If-None-Match": {
"equalTo": "\"4f508593b64df214fee8f6ab42df633c\""
"matches": "^(W/)?\"4f508593b64df214fee8f6ab42df633c\"$"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"method": "GET",
"headers": {
"If-None-Match": {
"equalTo": "\"4f508593b64df214fee8f6ab42df633c\""
"matches": "^(W/)?\"4f508593b64df214fee8f6ab42df633c\"$"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"method": "GET",
"headers": {
"If-None-Match": {
"equalTo": "\"4f508593b64df214fee8f6ab42df633c\""
"matches": "^(W/)?\"4f508593b64df214fee8f6ab42df633c\"$"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"method": "GET",
"headers": {
"If-None-Match": {
"equalTo": "\"31f73a7ecc35bbecec125851ce166af4\""
"matches": "^(W/)?\"31f73a7ecc35bbecec125851ce166af4\"$"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"method": "GET",
"headers": {
"If-None-Match": {
"equalTo": "\"31f73a7ecc35bbecec125851ce166af4\""
"matches": "^(W/)?\"31f73a7ecc35bbecec125851ce166af4\"$"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
"name": "repos_hub4j-test-org_github-api",
"request": {
"url": "/repos/hub4j-test-org/github-api",
"method": "GET"
"method": "GET",
"headers": {
"If-None-Match": {
"absent" : true
}
}
},
"response": {
"status": 200,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"method": "GET",
"headers": {
"If-None-Match": {
"equalTo": "\"295ae3430c604f3d10b6eb145fe511b5\""
"matches": "^(W/)?\"295ae3430c604f3d10b6eb145fe511b5\"$"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"method": "GET",
"headers": {
"If-None-Match": {
"equalTo": "\"295ae3430c604f3d10b6eb145fe511b5\""
"matches": "^(W/)?\"295ae3430c604f3d10b6eb145fe511b5\"$"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
"name": "repos_hub4j-test-org_github-api",
"request": {
"url": "/repos/hub4j-test-org/github-api",
"method": "GET"
"method": "GET",
"headers": {
"If-None-Match": {
"matches": "^(W/)?\"295ae3430c604f3d10b6eb145fe511b5\"$"
}
}
},
"response": {
"status": 304,
Expand Down