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

OkHttpClientTestRule check connectionCount instead of idle #5226

Merged
merged 3 commits into from
Jun 26, 2019

Conversation

yschimke
Copy link
Collaborator

Clients should be clean after use, not just from idle connections.

Clients should be clean after use, not just from idle connections.
@yschimke
Copy link
Collaborator Author

hmmm... maybe can't land without some fixes, probably a good sign?

@swankjesse
Copy link
Collaborator

Interesting!

@@ -84,6 +84,7 @@
clientListener.assertExhausted();

// TODO: assert all connections are released once leaks are fixed
clientTestRule.abandonClient(client);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment above makes it clear why this test was failing...

The rule is still worth using here to standardise the test client creation, but we just don't end up with clean client instances.

val connectionPool = prototype!!.connectionPool
connectionPool.evictAll()
assertThat(connectionPool.idleConnectionCount()).isEqualTo(0)
prototype?.let {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using let over simple if check because of a mutable field

@swankjesse swankjesse merged commit d81ec0f into square:master Jun 26, 2019
@yschimke yschimke deleted the client_test_evict branch July 19, 2019 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants