jmx-dev RFR: 8206187: javax/management/remote/mandatory/connection/DefaultAgentFilterTest.java fails with Port already in use
Kevin Walls
kevinw at openjdk.java.net
Wed Feb 23 14:15:18 UTC 2022
Test fails occasionally due to a port clash.
Presumably the port that was returned by Utils.getFreePort(), is no longer free.
The test creates a ProcessBuilder with the parameters for JMX, including port number, and uses that to create a new Process.
It should retry with a new port if we fail due to a port in use, for some limited number of attempts.
main already has some retry logic, but not working:
it checks for an InvocationTargetException to contain a BindException, but it simply gets a BindException, thrown by TestAppRun.start().
TestAppRun.start() runs the new process and scans for errors, but on failure its predicate has only seen the first line of a failure, so a BindException is never recognised and thrown.
Also main does not limit the retries, and handling the port retry in main() is duplicated, for each run of the test method.
So...
Make the error-scanning predicate in TestAppRun recognise a "port in use" message and throw a BindExeption. This is a notification to the caller that it failed, it's not the actual BindException as that was thrown in a different process.
Make the testDefaultAgent method (the main part of the test) handle retrying with a new port, a limited number of times.
-------------
Commit messages:
- Remove tab.
- Throw on last retry if port clash persists.
- Merge remote-tracking branch 'upstream/master' into 8206187_DefaultAgentFilterTest
- 8206187: javax/management/remote/mandatory/connection/DefaultAgentFilterTest.java fails with Port already in use
Changes: https://git.openjdk.java.net/jdk/pull/7589/files
Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=7589&range=00
Issue: https://bugs.openjdk.java.net/browse/JDK-8206187
Stats: 73 lines in 1 file changed: 25 ins; 29 del; 19 mod
Patch: https://git.openjdk.java.net/jdk/pull/7589.diff
Fetch: git fetch https://git.openjdk.java.net/jdk pull/7589/head:pull/7589
PR: https://git.openjdk.java.net/jdk/pull/7589
More information about the jmx-dev
mailing list