Commit 8696889
committed
Add optional Executor to CopilotClientOptions; wire all internal *Async calls through it; shared timeout scheduler.
src/main/java/com/github/copilot/sdk/json/CopilotClientOptions.java
- Added `Executor` field, `getExecutor()`, fluent `setExecutor(Executor)` with pending-null guard, and clone support.
src/main/java/com/github/copilot/sdk/CopilotClient.java
- Extracted `startCoreBody()` from `startCore()` lambda; `supplyAsync` uses provided executor when non-null.
- `stop()` routes session-close `runAsync` through provided executor when non-null.
- Passes executor to `RpcHandlerDispatcher` constructor.
- Sets executor on new sessions via `session.setExecutor()` in `createSession` and `resumeSession`.
src/main/java/com/github/copilot/sdk/RpcHandlerDispatcher.java
- Added `Executor` field and 3-arg constructor.
- All 5 `CompletableFuture.runAsync()` calls now go through private `runAsync(Runnable)` helper that uses executor when non-null.
src/main/java/com/github/copilot/sdk/CopilotSession.java
- Added `Executor` field and package-private `setExecutor()`.
- Replaced per-call `ScheduledExecutorService` with shared `timeoutScheduler` (daemon thread, shut down in `close()`).
- `executeToolAndRespondAsync` and `executePermissionAndRespondAsync` use executor when non-null.
src/test/java/com/github/copilot/sdk/ExecutorWiringTest.java (new)
- 6 E2E tests using `TrackingExecutor` decorator to verify all `*Async` paths route through the provided executor: client start, tool call, permission, user input, hooks, and client stop.
src/test/java/com/github/copilot/sdk/RpcHandlerDispatcherTest.java
- Updated constructor call to pass `null` for new executor parameter.1 parent a36d145 commit 8696889
File tree
6 files changed
+497
-44
lines changed- src
- main/java/com/github/copilot/sdk
- json
- test/java/com/github/copilot/sdk
6 files changed
+497
-44
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
150 | 151 | | |
151 | 152 | | |
152 | 153 | | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
168 | 159 | | |
169 | | - | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
170 | 175 | | |
171 | | - | |
172 | | - | |
173 | | - | |
| 176 | + | |
174 | 177 | | |
175 | | - | |
176 | | - | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
177 | 182 | | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
187 | 193 | | |
188 | | - | |
| 194 | + | |
| 195 | + | |
189 | 196 | | |
190 | 197 | | |
191 | 198 | | |
| |||
228 | 235 | | |
229 | 236 | | |
230 | 237 | | |
| 238 | + | |
231 | 239 | | |
232 | 240 | | |
233 | | - | |
| 241 | + | |
234 | 242 | | |
235 | 243 | | |
236 | 244 | | |
237 | 245 | | |
238 | 246 | | |
239 | | - | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
240 | 251 | | |
241 | 252 | | |
242 | 253 | | |
| |||
329 | 340 | | |
330 | 341 | | |
331 | 342 | | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
332 | 346 | | |
333 | 347 | | |
334 | 348 | | |
| |||
399 | 413 | | |
400 | 414 | | |
401 | 415 | | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
402 | 419 | | |
403 | 420 | | |
404 | 421 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
123 | 124 | | |
124 | 125 | | |
125 | 126 | | |
| 127 | + | |
126 | 128 | | |
127 | 129 | | |
128 | 130 | | |
| |||
166 | 168 | | |
167 | 169 | | |
168 | 170 | | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
169 | 179 | | |
170 | 180 | | |
171 | 181 | | |
| |||
651 | 661 | | |
652 | 662 | | |
653 | 663 | | |
654 | | - | |
| 664 | + | |
655 | 665 | | |
656 | 666 | | |
657 | 667 | | |
| |||
696 | 706 | | |
697 | 707 | | |
698 | 708 | | |
699 | | - | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
700 | 715 | | |
701 | 716 | | |
702 | 717 | | |
| |||
705 | 720 | | |
706 | 721 | | |
707 | 722 | | |
708 | | - | |
| 723 | + | |
709 | 724 | | |
710 | 725 | | |
711 | 726 | | |
| |||
744 | 759 | | |
745 | 760 | | |
746 | 761 | | |
747 | | - | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
748 | 768 | | |
749 | 769 | | |
750 | 770 | | |
| |||
Lines changed: 20 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
| 49 | + | |
48 | 50 | | |
49 | 51 | | |
50 | 52 | | |
| |||
53 | 55 | | |
54 | 56 | | |
55 | 57 | | |
| 58 | + | |
| 59 | + | |
56 | 60 | | |
57 | | - | |
| 61 | + | |
| 62 | + | |
58 | 63 | | |
59 | 64 | | |
| 65 | + | |
60 | 66 | | |
61 | 67 | | |
62 | 68 | | |
| |||
118 | 124 | | |
119 | 125 | | |
120 | 126 | | |
121 | | - | |
| 127 | + | |
122 | 128 | | |
123 | 129 | | |
124 | 130 | | |
| |||
178 | 184 | | |
179 | 185 | | |
180 | 186 | | |
181 | | - | |
| 187 | + | |
182 | 188 | | |
183 | 189 | | |
184 | 190 | | |
| |||
222 | 228 | | |
223 | 229 | | |
224 | 230 | | |
225 | | - | |
| 231 | + | |
226 | 232 | | |
227 | 233 | | |
228 | 234 | | |
| |||
278 | 284 | | |
279 | 285 | | |
280 | 286 | | |
281 | | - | |
| 287 | + | |
282 | 288 | | |
283 | 289 | | |
284 | 290 | | |
| |||
321 | 327 | | |
322 | 328 | | |
323 | 329 | | |
324 | | - | |
| 330 | + | |
325 | 331 | | |
326 | 332 | | |
327 | 333 | | |
| |||
359 | 365 | | |
360 | 366 | | |
361 | 367 | | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
362 | 376 | | |
Lines changed: 34 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
| 53 | + | |
52 | 54 | | |
53 | 55 | | |
54 | 56 | | |
| |||
412 | 414 | | |
413 | 415 | | |
414 | 416 | | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
415 | 448 | | |
416 | 449 | | |
417 | 450 | | |
| |||
439 | 472 | | |
440 | 473 | | |
441 | 474 | | |
| 475 | + | |
442 | 476 | | |
443 | 477 | | |
444 | 478 | | |
0 commit comments