Skip to content

Commit 1f7e796

Browse files
amirlivnehswankjesse
authored andcommitted
Cleanup HttpLoggingInterceptor (#4346)
* Use try-with-resources * Make bodyHasUnknownEncoding() static * Fix nits in HttpLoggingInterceptorTest * Revert "Use try-with-resources" This reverts commit 57dcd61.
1 parent ef34a41 commit 1f7e796

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

okhttp-logging-interceptor/src/main/java/okhttp3/logging/HttpLoggingInterceptor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ static boolean isPlaintext(Buffer buffer) {
326326
}
327327
}
328328

329-
private boolean bodyHasUnknownEncoding(Headers headers) {
329+
private static boolean bodyHasUnknownEncoding(Headers headers) {
330330
String contentEncoding = headers.get("Content-Encoding");
331331
return contentEncoding != null
332332
&& !contentEncoding.equalsIgnoreCase("identity")

okhttp-logging-interceptor/src/test/java/okhttp3/logging/HttpLoggingInterceptorTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ public final class HttpLoggingInterceptorTest {
5959

6060
@Rule public final MockWebServer server = new MockWebServer();
6161

62-
private HandshakeCertificates handshakeCertificates = localhost();
63-
private HostnameVerifier hostnameVerifier = new RecordingHostnameVerifier();
62+
private final HandshakeCertificates handshakeCertificates = localhost();
63+
private final HostnameVerifier hostnameVerifier = new RecordingHostnameVerifier();
6464
private OkHttpClient client;
6565
private String host;
6666
private HttpUrl url;
@@ -650,7 +650,7 @@ private void bodyGetNoBody(int code) throws IOException {
650650
.assertNoMoreLogs();
651651
}
652652

653-
@Test public void isPlaintext() throws IOException {
653+
@Test public void isPlaintext() {
654654
assertTrue(HttpLoggingInterceptor.isPlaintext(new Buffer()));
655655
assertTrue(HttpLoggingInterceptor.isPlaintext(new Buffer().writeUtf8("abc")));
656656
assertTrue(HttpLoggingInterceptor.isPlaintext(new Buffer().writeUtf8("new\r\nlines")));

0 commit comments

Comments
 (0)