A DESCRIPTION OF THE PROBLEM :
The PR https://github.com/square/okhttp/pull/6616 shows a test using OkHttp client to connect to a local mock server. It fails around 50% of the time.
The sun.security.util.MemoryCache inside sun.security.ssl.SSLSessionContextImpl appears to be unreliable as to when it will clear out entries.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Checkout https://github.com/square/okhttp and switch to PR https://github.com/square/okhttp/pull/6616
Run the test SessionReuseTest
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Test should confirm that two sequential requests with fresh connections reuse the same SSL session.
ACTUAL -
Test fails because a second session is created. Debugging is difficult because the logic in sun.security.ssl.SSLSessionContextImpl is JDK internal, but by the time the second client lookup via "localhost:50701" type key is made the cache is empty again.
FREQUENCY : often