1
0
mirror of https://github.com/square/okhttp.git synced 2025-11-24 18:41:06 +03:00

Test for connection leaks in more tests

This will help prevent regressions and point to the leaking test, rather than to a later test that happens to checks for leaks. The change is applied to all tests that have an OkHttpClient member variable.
This commit is contained in:
Amir Livneh
2019-03-02 16:30:33 -05:00
parent c78269c364
commit 851e37f52a
14 changed files with 63 additions and 9 deletions

View File

@@ -23,6 +23,8 @@ import java.util.Collections;
import java.util.List;
import okhttp3.internal.http2.Header;
import static org.junit.Assert.assertEquals;
public final class TestUtil {
public static final InetSocketAddress UNREACHABLE_ADDRESS
= new InetSocketAddress("198.51.100.1", 8080);
@@ -83,4 +85,9 @@ public final class TestUtil {
Thread.sleep(100);
System.runFinalization();
}
public static void ensureAllConnectionsReleased(OkHttpClient client) {
client.connectionPool().evictAll();
assertEquals(0, client.connectionPool().idleConnectionCount());
}
}