Skip to content

[CI] Check the exception type in the timeout tests, not its message - #43

Merged
PetrHeinz merged 1 commit into
mainfrom
claude/connect-timeout-test
Sep 29, 2026
Merged

PetrHeinz merged 1 commit into
mainfrom
claude/connect-timeout-test

Conversation

@PetrHeinz

Copy link
Copy Markdown
Member

testConnectTimeout fails now and then on Java 8. In this run of #35 the Java 8 job failed twice with a NullPointerException at LogtailAppenderTimeoutTest.java:44 and passed on its third attempt, so the build's retries hid it.

The test sets a 1 ms connect timeout against a non-routable address and compared the exception's message with "connect timed out". On Java 8, HttpURLConnection connects through SocksSocketImpl, which asks the proxy selector between starting the clock and the connection attempt. When the time is up by then, it throws a SocketTimeoutException without a message, and the test called toLowerCase() on null. On Java 11, 17 and 21 the connection does not go through SocksSocketImpl and the message is always there.

Both tests of the class now check that the exception is a SocketTimeoutException. What tells a connect timeout from a read timeout is the endpoint each test uses: the non-routable address never gets as far as reading, and the local socket that accepts and never answers connects at once.

Run in a fresh JVM each time on Java 8 (Temurin in Docker):

  • Before, 4 of 30 runs failed, all with that NullPointerException. Now 60 of 60 pass, 5 of them with the exception that has no message.
  • With a proxy selector that takes 20 ms to answer, which forces that case, the old assertion fails every time and the new one passes.
  • Java 11, 17 and 21 pass 30 of 30 before and after.

The failure is intermittent, so this comes without a failing-tests-first commit.

🤖 Generated with Claude Code

On Java 8 a 1 ms connect timeout can run out before the connection attempt
starts: SocksSocketImpl asks the proxy selector in between and then throws a
SocketTimeoutException without a message, on which testConnectTimeout called
toLowerCase(). Both tests now check for a SocketTimeoutException.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@PetrHeinz
PetrHeinz marked this pull request as ready for review September 29, 2026 12:36
@PetrHeinz
PetrHeinz merged commit 9871e1d into main Sep 29, 2026
5 checks passed
@PetrHeinz
PetrHeinz deleted the claude/connect-timeout-test branch September 29, 2026 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant