Commit c690301
fix: prevent duplicate shutdown hooks and replace e.printStackTrace() in CassandraConnector (#1183)
Two issues fixed:
1. prepareSession() called registerShutdownHook() on every invocation.
If getSession() triggered re-preparation (stale/closed session),
multiple hooks were registered for the same operation. Added a
shutdownHookRegistered boolean guard to ensure exactly one hook is
registered for the lifetime of the process.
2. e.printStackTrace() in the catch block sent stack traces to stderr
without context. Replaced with TelemetryManager.error() for consistent,
structured logging.
3. close() now iterates sessions individually with per-session error
handling so a failure on one session does not abort closing others,
and clears the map after shutdown.
Co-authored-by: Claude <claude@anthropic.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent 6c2a9a5 commit c690301
File tree
1 file changed
+24
-7
lines changed- platform-core/cassandra-connector/src/main/java/org/sunbird/cassandra
1 file changed
+24
-7
lines changedLines changed: 24 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
25 | 28 | | |
26 | 29 | | |
27 | 30 | | |
| |||
77 | 80 | | |
78 | 81 | | |
79 | 82 | | |
80 | | - | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
81 | 87 | | |
82 | | - | |
83 | 88 | | |
84 | 89 | | |
85 | 90 | | |
| |||
129 | 134 | | |
130 | 135 | | |
131 | 136 | | |
132 | | - | |
133 | | - | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
134 | 140 | | |
135 | 141 | | |
136 | | - | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
137 | 152 | | |
138 | 153 | | |
139 | 154 | | |
140 | | - | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
141 | 158 | | |
142 | 159 | | |
143 | 160 | | |
144 | 161 | | |
145 | 162 | | |
146 | | - | |
| 163 | + | |
147 | 164 | | |
148 | 165 | | |
149 | 166 | | |
| |||
0 commit comments