Fix potential race between Logger configuration and GCs in HttpURLConWithProxy test
Charlie Gracie
Charlie.Gracie at microsoft.com
Wed Jul 22 19:38:26 UTC 2020
Hi,
I believe there was a subtle timing hole introduced into the HttpURLConWithProxy.java test with the
fix for JDK-8183369 [1]. In our local tests, when using GC stress modes, we consistently get a failure
reported as:
"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 [2]. 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:
http://cr.openjdk.java.net/~burban/cgracie/logger_fix/webrev0.0/
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.
-vmoption:-XX:+UseShenandoahGC
-vmoption:-XX:+UnlockDiagnosticVMOptions
-vmoption:-XX:ShenandoahGCHeuristics=aggressive
Thanks,
Charlie Gracie
[1] https://bugs.openjdk.java.net/browse/JDK-8183369
[2] https://docs.oracle.com/en/java/javase/14/docs/api/java.logging/java/util/logging/Logger.html#getLogger(java.lang.String)
More information about the net-dev
mailing list