Commit d21261e
SSLIOSession: Fix regression in backpressure handling
A regression was introduced by PR #513, submitted as a fix for
HTTPCORE-775, which claimed that `SSLIOSession::write` was failing to
"handle" `SSLEngineResult#BUFFER_OVERFLOW`. The issue was encountered by
Apache CXF, who provided a test case demonstrating the problem:
https://github.com/apache/cxf/pull/2214/changes
I investigated this reproducer and found that CXF was actually hanging
due to not signaling the availability of more data:
https://github.com/apache/cxf/blob/f1b2c37bd9f3606cf7ca2d5d39cc1168e94fd9e4/rt/transports/http-hc5/src/main/java/org/apache/cxf/transport/http/asyncclient/hc5/CXFHttpAsyncRequestProducer.java#L97
when `SSLIOSession#write` signaled backpressure here:
https://github.com/apache/cxf/blob/f1b2c37bd9f3606cf7ca2d5d39cc1168e94fd9e4/rt/transports/http-hc5/src/main/java/org/apache/cxf/transport/http/asyncclient/hc5/CXFHttpAsyncRequestProducer.java#L75
The return value of `buf.produceContent` (which is ultimately
`SSLEngineResult#bytesConsumed` -- 0, in this case) is simply being
discarded. Changing the `CXFHttpAsyncRequestProducer#available` method
as follows causes the problematic test cases to succeed instantly:
```
@OverRide
public int available() {
if (buffer != null && buffer.hasRemaining()) {
return buffer.remaining();
} else if (buf != null && buf.length() > 0) {
return buf.length();
}
return 0;
}
```
Additionally, that PR appears to have introduced dysfunctional
backpressure handling into `SSLIOSession` by simply expanding the buffer
as much as necessary to hold the encrypted `src` buffer. This in turn
has caused a significant regression in heap usage and latency, hence the
need to revert. I've retained the test changes, since they did introduce
more coverage for TLSv1.3.1 parent fdc53a3 commit d21261e
3 files changed
Lines changed: 10 additions & 66 deletions
File tree
- httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio
- httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
750 | 750 | | |
751 | 751 | | |
752 | 752 | | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
753 | 756 | | |
754 | 757 | | |
755 | 758 | | |
| |||
Lines changed: 6 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
96 | | - | |
97 | 96 | | |
98 | 97 | | |
99 | 98 | | |
| |||
180 | 179 | | |
181 | 180 | | |
182 | 181 | | |
183 | | - | |
184 | | - | |
185 | | - | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
186 | 185 | | |
187 | 186 | | |
188 | 187 | | |
| |||
670 | 669 | | |
671 | 670 | | |
672 | 671 | | |
673 | | - | |
674 | | - | |
675 | | - | |
676 | | - | |
677 | | - | |
678 | | - | |
679 | | - | |
680 | | - | |
681 | | - | |
682 | | - | |
683 | | - | |
684 | | - | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
685 | 675 | | |
686 | 676 | | |
687 | 677 | | |
| |||
Lines changed: 1 addition & 50 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | 60 | | |
102 | 61 | | |
103 | 62 | | |
104 | 63 | | |
105 | 64 | | |
106 | 65 | | |
107 | | - | |
| 66 | + | |
108 | 67 | | |
109 | 68 | | |
110 | 69 | | |
| |||
131 | 90 | | |
132 | 91 | | |
133 | 92 | | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | 93 | | |
139 | 94 | | |
140 | 95 | | |
| |||
171 | 126 | | |
172 | 127 | | |
173 | 128 | | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | 129 | | |
179 | 130 | | |
180 | 131 | | |
0 commit comments