Commit 6bcdba2
authored
[fel] Improve McpClient lifecycle management with closed state tracking (#146)
- Added a closed flag to DefaultMcpClient to track client lifecycle state.
- Prevent method invocations after closure by adding checks in initialize(), getTools(), and callTool().
- Safely handle potential nulls in close() to avoid exceptions during partial initialization.
- Ensures consistent behavior and prevents resource leaks or usage after the client has been closed.
This change improves reliability and correctness by enforcing proper usage of the MCP client throughout its lifecycle.1 parent 6417d6e commit 6bcdba2
File tree
1 file changed
+18
-3
lines changed- framework/fel/java/plugins/tool-mcp-client/src/main/java/modelengine/fel/tool/mcp/client/support
1 file changed
+18
-3
lines changedLines changed: 18 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| 73 | + | |
73 | 74 | | |
74 | 75 | | |
75 | 76 | | |
| |||
99 | 100 | | |
100 | 101 | | |
101 | 102 | | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
102 | 106 | | |
103 | 107 | | |
104 | 108 | | |
| |||
116 | 120 | | |
117 | 121 | | |
118 | 122 | | |
119 | | - | |
120 | 123 | | |
| 124 | + | |
121 | 125 | | |
122 | 126 | | |
123 | 127 | | |
| |||
242 | 246 | | |
243 | 247 | | |
244 | 248 | | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
245 | 252 | | |
246 | 253 | | |
247 | 254 | | |
| |||
278 | 285 | | |
279 | 286 | | |
280 | 287 | | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
281 | 291 | | |
282 | 292 | | |
283 | 293 | | |
| |||
383 | 393 | | |
384 | 394 | | |
385 | 395 | | |
386 | | - | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
387 | 400 | | |
388 | | - | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
389 | 404 | | |
390 | 405 | | |
391 | 406 | | |
| |||
0 commit comments