Fix potential race between Logger configuration and GCs in HttpURLConWithProxy test
Charlie.Gracie at microsoft.com
Wed Jul 22 19:38:26 UTC 2020
I believe there was a subtle timing hole introduced into the HttpURLConWithProxy.java test with the
fix for JDK-8183369 . In our local tests, when using GC stress modes, we consistently get a failure
"Execution failed: `main' threw exception: java.lang.RuntimeException: Connection not retried with proxy".
I verified that the Proxy is being used but the messages are not being logged with the ProxyHandler. The
issue is caused by back to back calls of Logger.getLogger(String). If a GC happens between the two calls
there is no guarantee that the same object will be returned . Since the test relies on the log messages
being handled by the new ProxyHandler to pass, it needs to ensure the Logger object lives the entire
lifetime of the test.
Here is my proposed fix:
The easiest way to reproduce is to use the following vm options when running the specific test. These options
will force the Shenandoah GC into a continuous GC mode making the test fail almost 100% of the time.
More information about the net-dev