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:
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user