History log of /external/okhttp/okhttp-tests/src/test/java/com/squareup/okhttp/ConnectionPoolTest.java
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
f3bcd0c7f0741b277b5d58f294df6201dafd45e8 19-Nov-2014 Neil Fuller <nfuller@google.com> Fix for a socket leak in OkHttp on Android

When the preferred Android network changes from
cell -> wifi or wifi -> cell the HTTP connection
pool in use is abandoned to avoid reuse of
connections on the old network. This was added
in commit 8bced3e.

The design for the connection pool was such that
continuous use of the connection pool was required to
clean up idle / expired connections. If a connection
pool becomes idle (as when it is dereferenced on a
network change) it is possible for some connections
to remain in the pool indefinitely.

After the preferred network change, because the old
connection pool was no longer referenced the pool
would be garbage collected and Android's "Strict Mode"
would complain about sockets not being closed.

The only existing way to avoid this was to call
"evictAll()", which would have had issues when a
large number of connections were returned to the pool
after evictAll() was called. It also wouldn't work
for SPDY connections which are shared but not reference
counted, which makes knowing whether it is safe to
close them difficult. SPDY is not enabled on Android
by default and so that may have been safe to ignore.

This fix tries to keep the existing cleaning behavior
intact to avoid introducing new bugs or new thread
behavior that might impact battery life. It adds a
new mode to the pool for "draining", which handles
cleaning up any existing entries in the pool and any
added after the pool has been placed into draining
mode.

The drainModeRunnable introduced serves two purposes:

1) While scheduled / executing, it pins the connection
pool in memory to avoid it being garbage collected.
2) It continues to close connections (safely) until the
pool is empty.

If a connection is then added back to the pool the
drainModeRunnable is restarted.

Bug: 18369687
(cherry picked from commit ff345b6c0ffcc691e4c3c594f8a222cf81bb325c)

Change-Id: I4e9e530f8e7acedf4b9a806237c8769a10671feb
/external/okhttp/okhttp-tests/src/test/java/com/squareup/okhttp/ConnectionPoolTest.java
3f968acf193178145e9d227f2f08b95e2d6a6c26 15-Apr-2014 Jake Wharton <jw@squareup.com> Allow specifying a socket factory for connections.

This socket factory will be used for all non-proxy connections and HTTP proxy connections.

This is a clean cherry-pick of:
https://github.com/square/okhttp/commit/ff5390d6dcaf79ef09a3ef94dbb7e8ac39572a7f

That was committed about two weeks after we pulled our current
snapshot, so we would have picked this change up on the next
sync with upstream.

Bug: 11826069

(cherry picked from commit e5baca5e4c9de92820a38e60e289d07f1acaa2ef)

Change-Id: Ica683022e6963a0a4f0c3fd1a33c1b843e307c1a
/external/okhttp/okhttp-tests/src/test/java/com/squareup/okhttp/ConnectionPoolTest.java
78092f38ebd93018ead53a87b53118dc829cbb8a 01-Apr-2014 Neil Fuller <nfuller@google.com> Pull upstream fixes from OkHttp

This synced to commit b21b40e480cdcd09b618e399a349556de509d88d
/ master / 1st April 2014.

Notably this contains a fix for apps that bundle an older
copy of OkHttp or which call android.net.http.HttpResponseCache.get()
or android.net.http.HttpResponseCache.put().

See for details:
https://github.com/square/okhttp/pull/672

Change-Id: I90acd9f9946014e834ea203dbc62cdcf7bc80cc6
/external/okhttp/okhttp-tests/src/test/java/com/squareup/okhttp/ConnectionPoolTest.java
3c938a3f6b61ce5e2dba0d039b03fe73b89fd26c 19-Feb-2014 Neil Fuller <nfuller@google.com> Update okhttp to a more recent commit.

Updating to upstream commit : 7b106923e078ac2435e8c8ce9d615f9903106ed8
/ 7th Mar 2014 / main branch.

The following changes were made to Android-only code:
1) HttpsHandler has been changed to deal with the fix for:
https://github.com/square/okhttp/issues/184 (commit 5d7fdba).
2) Platform.java changed to accomodate changes in okhttp Platform
method signatures.
3) .mk file updates to reflect src directory changes.

The following changes were made to OkHttp code:
1) Removal of org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
annotation from okio/src/main/java/okio/DeflaterSink.java

Change-Id: I644a883482ac7ee7d029785f110a2ca00762419b
/external/okhttp/okhttp-tests/src/test/java/com/squareup/okhttp/ConnectionPoolTest.java