Commit 5b3abb5
Java SDK: emit JSON-RPC error on pending-buffer overflow + guard drop
Carries forward the Rust SDK PR #1394 review feedback into the Java port:
1. Cap the per-session inbound-request parked-waiter list at 128
(BUFFER_LIMIT). When exceeded, evict the oldest waiter via
completeExceptionally("pending session buffer overflow"). The
RpcHandlerDispatcher thread blocked in waiter.get() wakes up, catches
ExecutionException, and resolveSessionForRequest calls
rpc.sendErrorResponse(-32603, ...) so the runtime isn't left waiting
on a request id that will never get a reply. Mirrors Rust commit
491b442 and TS commit c167bc3 on PR #1395.
2. decrementGuard now completes all stale waiters internally with a
distinct message ("pending session routing ended before session was
registered") instead of returning them for callers to complete with
ad-hoc strings. A single canonical message lets debugging tell the
overflow-eviction path from the create-failed path. Mirrors Rust
commit e0ff254 and TS commit c167bc3.
3. Fix isDone() fast path in resolveSessionForRequest: the existing
catch-all "fall through" swallowed ExecutionException from an
overflow-evicted waiter, sending a generic -32602 "Unknown session"
error instead of -32603. Now explicitly catches ExecutionException in
the isDone() branch and sends the same -32603 error as the blocking
path.
Adds two new unit tests in CloudSessionTest:
- parkedRequestWaiterBuffer_overflow_evictsOldestWithOverflowMessage:
parks 129 waiters, verifies oldest completes with "pending session
buffer overflow", remaining 128 resolve normally after registration.
- parkedRequestWaiter_guardDropMessage_isDistinctFromOverflowMessage:
parks a request via the full handler path, drops the guard without
registration, verifies the JSON-RPC error response contains "routing
ended before session was registered" but not "buffer overflow".
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 1a46990 commit 5b3abb5
4 files changed
Lines changed: 146 additions & 47 deletions
File tree
- java/src
- main/java/com/github/copilot/sdk
- test/java/com/github/copilot/sdk
Lines changed: 5 additions & 22 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
583 | 583 | | |
584 | 584 | | |
585 | 585 | | |
586 | | - | |
587 | | - | |
588 | | - | |
| 586 | + | |
589 | 587 | | |
590 | 588 | | |
591 | 589 | | |
| |||
619 | 617 | | |
620 | 618 | | |
621 | 619 | | |
622 | | - | |
| 620 | + | |
623 | 621 | | |
624 | | - | |
625 | | - | |
626 | | - | |
| 622 | + | |
627 | 623 | | |
628 | 624 | | |
629 | 625 | | |
630 | 626 | | |
631 | 627 | | |
632 | 628 | | |
633 | | - | |
634 | | - | |
635 | | - | |
| 629 | + | |
636 | 630 | | |
637 | 631 | | |
638 | 632 | | |
639 | 633 | | |
640 | 634 | | |
641 | 635 | | |
642 | | - | |
643 | | - | |
| 636 | + | |
644 | 637 | | |
645 | 638 | | |
646 | 639 | | |
647 | 640 | | |
648 | 641 | | |
649 | 642 | | |
650 | 643 | | |
651 | | - | |
652 | | - | |
653 | | - | |
654 | | - | |
655 | | - | |
656 | | - | |
657 | | - | |
658 | | - | |
659 | | - | |
660 | | - | |
661 | 644 | | |
662 | 645 | | |
663 | 646 | | |
| |||
Lines changed: 35 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
| 59 | + | |
| 60 | + | |
63 | 61 | | |
64 | | - | |
| 62 | + | |
65 | 63 | | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
71 | 83 | | |
72 | | - | |
73 | | - | |
74 | 84 | | |
75 | | - | |
76 | 85 | | |
77 | 86 | | |
78 | 87 | | |
| |||
137 | 146 | | |
138 | 147 | | |
139 | 148 | | |
140 | | - | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
141 | 162 | | |
142 | 163 | | |
143 | 164 | | |
| |||
Lines changed: 14 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
570 | 570 | | |
571 | 571 | | |
572 | 572 | | |
573 | | - | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
574 | 578 | | |
575 | 579 | | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
576 | 589 | | |
577 | 590 | | |
578 | 591 | | |
| |||
Lines changed: 92 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
306 | 306 | | |
307 | 307 | | |
308 | 308 | | |
309 | | - | |
310 | | - | |
| 309 | + | |
311 | 310 | | |
312 | 311 | | |
313 | 312 | | |
| |||
413 | 412 | | |
414 | 413 | | |
415 | 414 | | |
416 | | - | |
417 | | - | |
418 | | - | |
419 | | - | |
420 | | - | |
421 | | - | |
422 | | - | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
423 | 418 | | |
424 | | - | |
| 419 | + | |
425 | 420 | | |
426 | 421 | | |
427 | 422 | | |
428 | 423 | | |
429 | 424 | | |
430 | 425 | | |
431 | 426 | | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
432 | 514 | | |
433 | 515 | | |
0 commit comments