Skip to content

test(client): use an ephemeral registration port - #7184

Merged
Aias00 merged 2 commits into
apache:masterfrom
dengliming:fix-6591-use-ephemeral-test-port
Oct 27, 2026
Merged

Aias00 merged 2 commits into
apache:masterfrom
dengliming:fix-6591-use-ephemeral-test-port

Conversation

@dengliming

Copy link
Copy Markdown
Member

Fixes #6591.

Uses an OS-assigned ephemeral port and try-with-resources in the URI registration test, avoiding collisions with other processes and guaranteeing socket cleanup when assertions fail.

Tests:

  • ShenyuClientURIExecutorSubscriberTest
  • Checkstyle

@Aias00 Aias00 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small but worthwhile test-hygiene fix.

The test previously did new ServerSocket(9527) — a hard-coded port that (a) collides if anything else on the CI runner is using 9527, and (b) was never closed, leaking a listening socket for the rest of the JVM's life. new ServerSocket(0) asks the OS for a free ephemeral port, and socket.getLocalPort() feeds that into the URIRegisterDTO, so the test still exercises the same code path without depending on a fixed port.

Wrapping it in try-with-resources guarantees the socket is released even if executorSubscriber.executor(...) throws, which also means a failure no longer poisons subsequent tests in the same fork.

Assertion (persistURI called once) is unchanged, so the test's intent is preserved.

@Aias00

Aias00 commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Ping on state: this PR is approved on the code, but pr_build fails and it cannot be merged yet.

Failed to execute goal ... on project shenyu-spring-boot-starter-client-beat: Could not resolve dependencies
Could not find artifact org.apache.shenyu:shenyu-register-client-beat:jar:2.7.2-SNAPSHOT in apache.snapshots

The path-filtered build left shenyu-register-client-beat out of the reactor, so its SNAPSHOT was not available. This is a CI build-scoping issue, not a defect in this change.

Please rerun the failed job; if it reproduces, a push (even a trivial rebase) re-evaluates the path filter and pulls the missing module in.

@Aias00

Aias00 commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

@dengliming This PR is approved, but the pr_build check is red. I looked at that job on several PRs today and it fails in shared test setup rather than in the diff: the MQTT SubscribeTest fixture throws NullPointerException: Cannot invoke "Object.hashCode()" because "key" is null at SubscribeTest.java:75/90 because the repositories are not registered in Singleton.INST (#8075 fixes exactly that), and another variant dies on a stale shenyu-register-client-beat artifact.

Please rebase onto master and push so CI re-runs. If pr_build is still red afterwards, paste the failing test and I'll take it from there.

@Aias00

Aias00 commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

@dengliming — a correction to the note I left here yesterday. The failures on this branch all predate the fix, so nothing in your change is implicated.

master went green at a8080ae: the SubscribeTest fixture isolation (#8092), the MQTT session scoping (#8093) and the pr_build dependency fix (#8075) all landed, and the latest ci.yml, integrated-test.yml and CodeQL runs on master are all success.

That means the red checks recorded here are stale. A push — an empty commit or a rebase, whichever is easier — re-runs them against the current baseline. I would not spend time reading the old logs.

@Aias00

Aias00 commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Hi @dengliming, this PR is already approved, but it currently cannot be merged. Here is the blocker and what is needed:

Blocker
This PR is approved but blocked. pr_build fails with a NullPointerException, but the run is from a stale base (2026-09-23).

What we need
Please rebase onto current master and re-trigger CI; if the NPE persists, share the stack trace.

Once the branch is up to date and CI is green, we will squash-merge it. Thanks!

@Aias00
Aias00 merged commit 4f6a1ce into apache:master Oct 27, 2026
28 checks passed
@Aias00 Aias00 added this to the 2.7.2 milestone Nov 13, 2026
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.

[BUG] Hardcoded port 9527 without finally cleanup (TOCTOU BindException)

2 participants