Commit 4bfe0db
GH-10671: Fix writingLatch lifecycle in TcpNioConnection
Inside `TcpNioConnection.ChannelInputStream.write()`, the implementation currently performs:
```
TcpNioConnection.this.writingLatch = new CountDownLatch(1);
```
This line replaces the latch with a new one after every write, even when the assembler is already waiting on the previous latch.
This leads to a lost‑notification race:
* Assembler enters `convert()`, captures latch A, and prepares to wait.
* Before the assembler actually calls `await()`, the `ChannelInputStream.write()` executes and replaces latch A with B.
* NIO reader signals B, but assembler is still waiting on A.
* A is never signaled → assembler waits the full 60s → Timed out waiting for IO.
* While assembler is blocked, the pipe cannot be drained → queue fills → Timed out waiting for buffer space.
Fix a lost-notify race in `TcpNioConnection` where `writingLatch` could be replaced from
`ChannelInputStream.write()`, causing the assembler to wait on a stale latch under concurrency.
Changes:
Do not replace `writingLatch` from the pipe write path
Clear `writingLatch` at the end of the `doRead()` cycle
Add a regression test proving the latch is not replaced during pipe write and is cleared after read
Signed-off-by: Outman Ouharri <ouharri.outman@gmail.com>
(cherry picked from commit 18c72d1)1 parent 047aea4 commit 4bfe0db
2 files changed
Lines changed: 57 additions & 1 deletion
File tree
- spring-integration-ip/src
- main/java/org/springframework/integration/ip/tcp/connection
- test/java/org/springframework/integration/ip/tcp/connection
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
483 | 483 | | |
484 | 484 | | |
485 | 485 | | |
| 486 | + | |
486 | 487 | | |
487 | 488 | | |
488 | 489 | | |
| |||
828 | 829 | | |
829 | 830 | | |
830 | 831 | | |
831 | | - | |
832 | 832 | | |
833 | 833 | | |
834 | 834 | | |
| |||
Lines changed: 56 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
798 | 798 | | |
799 | 799 | | |
800 | 800 | | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
801 | 857 | | |
802 | 858 | | |
803 | 859 | | |
| |||
0 commit comments