RFR: Ensure vthread has connected to server

Miao Zheng github.com+20216587+miao-zheng at openjdk.java.net
Mon Sep 6 11:02:43 UTC 2021


On Mon, 6 Sep 2021 10:13:13 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>> I have run the test case of InterruptHttp.java in fast debug version of jdk with options:
>> -XX:+UseG1GC  -XX:+ScavengeALot -XX:ScavengeALotInterval=200 -XX:-GCALotAtAllSafepoints
>> 
>> And the test case failed, The output is "Execution failed: `main' threw exception: java.lang.RuntimeException: Expected 1 HTTP connection"
>> 
>> The reason is Thread.sleep(1000) can not ensure that vthread has connected to server when using some options and fastdebug version of jdk.
>> 
>> So, I fix this to ensure vthread has connected to server.
>
> test/jdk/java/lang/Thread/virtual/InterruptHttp.java line 60:
> 
>> 58:             while (thread.getState() != Thread.State.WAITING) {
>> 59:                 Thread.sleep(1000);
>> 60:             }
> 
> Thanks for this. You are right that that the test is problematic. Can you try the following instead of polling the thread state? This will wait until a connection is established so that the read is interrupted.
> 
> 
> while (server.connectionCount() == 0) {
>     Thread.sleep(100);
> }

Thanks for your review.
Do I need remove this? I think the following is duplicated with the check of "server.connectionCount() == 0"

    // server should have accepted one connection
    if (server.connectionCount() != 1)
        throw new RuntimeException("Expected 1 HTTP connection");

-------------

PR: https://git.openjdk.java.net/loom/pull/60


More information about the loom-dev mailing list