On Thu, 12 Nov 2026 13:59:44 GMT, Volkan Yazici <[email protected]> wrote:
>> Add unit tests for the `jdk.httpserver` system properties. >> >> --------- >> - [X] I confirm that I make this contribution in accordance with the >> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai). > > Volkan Yazici has updated the pull request incrementally with four additional > commits since the last revision: > > - Implement wall-clock sleep > - Fix "pause before request line" case in `MaxReqTimePropertyTest` > - Verify the provided time configuration > - Skip timing-sensitive tests on exotic configurations I encountered failures with following logs: [22:47:52.025] STARTED MaxRspTimePropertyTest::testExcessivePause '[1] BEFORE_SENDING_HEADERS' Nov 11, 2026 10:47:52 PM MaxRspTimePropertyTest sendRequest INFO: Sending request Nov 11, 2026 10:47:52 PM MaxRspTimePropertyTest sendRequest INFO: Reading the response status line Nov 11, 2026 10:47:52 PM MaxRspTimePropertyTest$PausingHandler handle INFO: Received request Nov 11, 2026 10:47:52 PM MaxRspTimePropertyTest$PausingHandler flushAndPauseIfLocationMatches INFO: Flushing and pausing at BEFORE_SENDING_HEADERS Nov 11, 2026 10:47:55 PM MaxRspTimePropertyTest$PausingHandler handle INFO: Served request Nov 11, 2026 10:47:55 PM MaxRspTimePropertyTest sendRequest INFO: Reading the response headers Nov 11, 2026 10:47:55 PM MaxRspTimePropertyTest sendRequest INFO: Reading the response body org.opentest4j.AssertionFailedError: Expected java.net.SocketException to be thrown, but nothing was thrown. at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:152) at org.junit.jupiter.api.AssertThrows.assertThrows(AssertThrows.java:73) at org.junit.jupiter.api.AssertThrows.assertThrows(AssertThrows.java:35) at org.junit.jupiter.api.Assertions.assertThrows(Assertions.java:3128) at MaxRspTimePropertyTest.testExcessivePause(MaxRspTimePropertyTest.java:117) ... [22:47:55.067] FAILED MaxRspTimePropertyTest::testExcessivePause '[1] BEFORE_SENDING_HEADERS' [5115ms] Consider these particular lines: Nov 11, 2026 10:47:52 PM MaxRspTimePropertyTest$PausingHandler flushAndPauseIfLocationMatches INFO: Flushing and pausing at BEFORE_SENDING_HEADERS Nov 11, 2026 10:47:55 PM MaxRspTimePropertyTest$PausingHandler handle INFO: Served request ... [22:47:55.067] FAILED MaxRspTimePropertyTest::testExcessivePause '[1] BEFORE_SENDING_HEADERS' [5115ms] The `5115ms` at the bottom confirms that the server handler has slept for 5s as expected. Yet the wall clock time reports, `10:47:52..10:47:55`, 3 seconds! :exploding_head: Server's timing-sensitive mechanisms uses wall clock time; `java.util.Timer`, `System.currentTimeMillis()`, and so on. A small misalignment between the wall clock time and the monotonic elapsed time (used by `Thread.sleep()`, etc.) can easily invalidate tests' assumptions. As a band-aid, I have switched from `Thread.sleep()` to a busy loop using `System.currentTimeMillis()` in 9e8e24cfb5f. Yet, by introducing artificial delay to the server's scheduler/clock, I am still able to make some of the tests fail. At this stage, I am considering whether its the way server is designed causing these testing difficulties. Could we achieve more deterministic and faster tests if the server would allow tests to inject their custom schedulers/clocks? If we go with the current setup, could we ever achieve a stable-enough test suite that is not prone to occasional scheduler/clock jitter? ------------- PR Comment: https://git.openjdk.org/jdk/pull/31974#issuecomment-6825938292
