mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Valery Kharseko
18 hours ago cdc884c34f5d7f22624d4e85a8bb61fd50560e5e
refs
author Valery Kharseko <vharseko@3a-systems.ru>
Tuesday, November 3, 2026 11:44 +0100
committer GitHub <noreply@github.com>
Tuesday, November 3, 2026 11:44 +0100
commitcdc884c34f5d7f22624d4e85a8bb61fd50560e5e
tree 84d40331d6e49d87d5c58129641822e6f6c53250 tree | zip | gz
parent bcd00254cd86748aca2bb81cf4bb30267f1bc2a6 view | diff
[#1261] Close JMX RMI connector sockets on shutdown (#1264)

Fixes #1261.

With `rmi-port: 0`, every JMX handler start created a new RMI connector
listener that remained open after the handler stopped. Unexporting the
connector does not close an anonymous-port listener in the JDK. Repeated
embedded-server restarts therefore accumulated listening ports and
accept threads.

Retain the connector's socket factory and explicitly close its socket
after stopping the connector, for both plain and SSL connections. Both
factories implement `Closeable`, and the SSL factory now remembers its
server socket. Cleanup also runs if connector shutdown throws or a
configuration change keeps the RMI registry running. Repeated
finalization is safe.

The regression tests open real JMX sessions and verify that the old port
refuses connections and can be rebound after shutdown and after a
configuration change. They cover both SSL settings and three successive
handler start/stop cycles.

Validation on macOS:

- All four new regression cases failed on the original code because the
stopped listener still accepted connections.
- `JmxListenAddressTestCase` on JDK 27: 9 passed, 1 skipped.
- Full JMX package on JDK 17, using the Maven reactor and `precommit`
profile: 55 passed, 1 skipped; build successful.
- The existing wildcard-hostname case is skipped because the local
hostname resolves to loopback.
- `git diff --check` passed.
4 files modified
128 ■■■■■ changed files
opendj-server-legacy/src/main/java/org/opends/server/protocols/jmx/DirectoryRMIServerSocketFactory.java 24 ●●●●● diff | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/protocols/jmx/OpendsRmiServerSocketFactory.java 7 ●●●●● diff | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/protocols/jmx/RmiConnector.java 17 ●●●●● diff | view | raw | blame | history
opendj-server-legacy/src/test/java/org/opends/server/protocols/jmx/JmxListenAddressTestCase.java 80 ●●●●● diff | view | raw | blame | history