OPENDJ-1255 SEVERE_ERROR (Socket closed) in logs/errors file after uninstallation of a replicated server
Code review: Matthew Swift
Problem lied in the MonitoringPublisher thread which sends the monitoring information at regular intervals (60s by default).
In run(), code was waiting for 60s then happily sending the monitor message regardless of whether the server was shutting down.
However, if the thread is notified by shutdown process while waiting 60s, then it will immediately try to send the monitor message.
Since the shutdown is initiated, it will receive a SocketException when trying to send a monitor message. This exception is then logged.
Fix consisted in checking whether the server is shutting down right after being notified.
MonitoringPublisher.java:
Removed shutdown instance field (superseded by initiateShutdown() and isShuttingDown()).
In run(), moved the call to wait(long) at the end of the loop, so a notification will be immediately followed by a check on whether the server is shutting down + also added a shutdown check in the body of the loop.
In shutdown(), called initiateShutdown() before entering the synchronized block + moved the logging code outside of the synchronized block.
In waitForShutdown(), used Thread.join(long) instead of ill looking code.