On Tue, 3 Nov 2026 09:11:58 GMT, Volkan Yazici <[email protected]> wrote:

>> test/jdk/com/sun/net/httpserver/property/MaxConnectionsPropertyTest.java 
>> line 132:
>> 
>>> 130:                             // `assertThrows` expects 
>>> `SocketException` to verify disconnect.
>>> 131:                             // Use `SocketException` to signal EOF.
>>> 132:                             throw new SocketException("EOF");
>> 
>> Hello Volkan, I don't fully follow this assertThrows call. Should the 
>> `assertThrows` only wrap the `connectAndWriteRequest()` call? The 
>> `connectAndWriteRequest()` does a new `connect()` and then writes to the 
>> socket. Are you seeing a case where the connect followed by the write 
>> succeeds without any exception even when the connection limit imposed by the 
>> server is reached?
>
> 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");

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

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

Reply via email to