square/okio — pull request #86 by nfuller (2014-11-26 11:16:28+00:00)
Title: Make tests pass on Android and other platforms

Previously failing with:
okio.SocketTimeoutTest#writeWithTimeout
junit.framework.AssertionFailedError
at junit.framework.Assert.fail(Assert.java:56)
at okio.SocketTimeoutTest.writeWithTimeout(SocketTimeoutTest.java:75)

The problem: the 1MB of data can be written to the
client socket even though the server socket is not reading.
This is because sockets on Android are buffered by default
by more that the amount of data in the test. This prevents
the write timeout occurring.

Socket defaults measured on a Nexus 4 running AOSP:
send: 524288 bytes, receive: 1048576 bytes.
IIRC, it varies by device.

Only some of the buffers need to be set to fix this, but
setting all of them seems reasonable to make it explicit.
The buffers are set to 1/4 of the data being
transferred to ensure that the data will
flood the send and receive buffers with some to spare.
Too small and the "withoutTimeout" tests will timeout
due to inefficiency.

The tests were also failing on a Linux desktop, probably
for similar reasons.