On Tue, 3 Nov 2026 09:43:32 GMT, Jaikiran Pai <[email protected]> wrote:

>> Yes, almost every time. You can comment out the `if` block at line 129 and 
>> observe the test failure yourself locally.
>> 
>> `connectAndWriteRequest()` succeeding means the connection is established 
>> and the socket is accepted. The server checks the limit after `accept()`. 
>> Meanwhile, the client can complete the data delivery. Neither `flush()` 
>> waits for the server to read and process the bytes. The only reliable way to 
>> verify that the request is rejected is to read the disconnect issued by the 
>> server, hence the `read() == -1`.
>> 
>> Does this answer your question?
>
> The part that I am uncertain about in this line is, why would 
> `connectAndWriteRequest()` complete normally sometimes and on other 
> occassions fail with a `SocketException`. In other words, would the test work 
> as expected if it was changed to:
> 
> connectAndWriteRequest(server.getAddress(), lastSocket, "/?socket=last");
> assertEquals(-1, lastSocket.getInputStream().read(), "did not receive EOF");

@jaikiran, in 19056a61985, I needed to revert back to the old code.

> In other words, would the test work as expected if it was changed to:
> 
> connectAndWriteRequest(server.getAddress(), lastSocket, "/?socket=last");
> assertEquals(-1, lastSocket.getInputStream().read(), "did not receive EOF");

Earlier I was mistaken when I say this would work. No, it wouldn't, it doesn't. 
We should never be reading EOF,  since the handler simply blocks. See that the 
handler is released at the end via `serverHandlerUnblockSignal.countDown()`. On 
Windows, occasionally, `connectAndWriteRequest()` succeeds, and 
`lastSocket.getInputStream().read()` returns `-1`. We should throw 
`SocketException` when this  happens. Otherwise, the function passed to 
`assertThrows()` succeeds, and trips `assertThrows()`.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/31974#discussion_r4539386030

Reply via email to