Release the background resources a discarded runtime owns

Several resources outlived a disconnect on purpose, which was harmless while a
process ran exactly one session for its whole life. They are now released when
the controller itself is closed:

- the ON4KST connection supervisor thread, which stopByUser did not touch
- the sked reminder scheduler, which had no shutdown at all
- the reachability executor, whose shutdown method existed but was never called
- the PSTRotator retry scheduler and its pending retry
- the map tile proxy, whose stop method existed but was never called, leaving a
  server socket and a twelve thread pool behind
- the station map bridge listeners and its coalescing animation, which would
  otherwise keep firing into a dead user interface

These are real leaks today; they only become visible when a second runtime is
built in the same process.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hpa6bjie5qkeNG62y6FmXm
This commit is contained in:
Claude
2026-09-07 22:22:45 +02:00
committed by Rsclub2_2
parent 63a4bae858
commit 74ac1139ad
5 changed files with 134 additions and 12 deletions
@@ -1083,9 +1083,35 @@ public class ChatController implements ThreadStatusCallback, PstRotatorEventList
rotatorClient.stop();
rotatorClient = null;
}
releaseBackgroundExecutors();
}
}
/**
* Stops the background executors that live as long as this controller.
*
* <p>These are not bound to one ON4KST session, so disconnecting leaves them running
* on purpose. When the controller itself is discarded they have to go, otherwise a
* discarded controller stays reachable through its own threads.</p>
*/
private void releaseBackgroundExecutors() {
on4KstConnectionManager.shutdown();
skedReminderService.shutdown();
if (reachabilityService != null) {
reachabilityService.shutdown();
}
if (pendingRotatorRetry != null) {
pendingRotatorRetry.cancel(false);
pendingRotatorRetry = null;
}
rotatorCommandScheduler.shutdownNow();
}
private void cancelTimer(Timer timer) {
if (timer != null) {
timer.cancel();