Commit ac62ae7
committed
Fix file descriptor leaks in ServerStatusManager and ZooKeeperCommandExecutor
Motivation:
`Files.newInputStream()` and `Files.newOutputStream()` allocate real OS
file descriptors. `Properties.load()` and `Properties.store()` do not
close the stream passed to them, so the caller is responsible for
closing it. The descriptors are eventually reclaimed by GC, but GC is
triggered by memory pressure rather than FD exhaustion.
Modifications:
- `ServerStatusManager.serverStatus()`: wrap `Files.newInputStream()`
in try-with-resources so the stream is closed after `Properties.load()`.
- `ServerStatusManager.updateStatus()`: same fix for the load path;
also wrap `Files.newOutputStream()` in try-with-resources so the
stream is closed after `Properties.store()`.
Result:
- File descriptors opened for property file I/O are now released
deterministically instead of relying on GC finalisation.1 parent 99db9ec commit ac62ae7
2 files changed
Lines changed: 11 additions & 15 deletions
File tree
- server/src/main/java/com/linecorp/centraldogma/server
- internal/replication
- management
Lines changed: 3 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
772 | 772 | | |
773 | 773 | | |
774 | 774 | | |
775 | | - | |
776 | | - | |
777 | | - | |
778 | | - | |
779 | | - | |
780 | | - | |
781 | | - | |
782 | | - | |
| 775 | + | |
783 | 776 | | |
784 | 777 | | |
785 | 778 | | |
786 | 779 | | |
787 | 780 | | |
| 781 | + | |
| 782 | + | |
788 | 783 | | |
789 | 784 | | |
790 | 785 | | |
| |||
Lines changed: 8 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
| |||
65 | 67 | | |
66 | 68 | | |
67 | 69 | | |
68 | | - | |
69 | | - | |
| 70 | + | |
| 71 | + | |
70 | 72 | | |
71 | 73 | | |
72 | 74 | | |
| |||
85 | 87 | | |
86 | 88 | | |
87 | 89 | | |
88 | | - | |
89 | | - | |
| 90 | + | |
| 91 | + | |
90 | 92 | | |
91 | 93 | | |
92 | 94 | | |
93 | 95 | | |
94 | 96 | | |
95 | | - | |
96 | | - | |
97 | | - | |
| 97 | + | |
| 98 | + | |
98 | 99 | | |
99 | 100 | | |
100 | 101 | | |
| |||
0 commit comments