@@ -85,26 +85,27 @@ private Http2TestUtil() {
85
85
}
86
86
87
87
static class FrameAdapter extends ByteToMessageDecoder {
88
- private final boolean copyBufs ;
88
+ private final boolean retainBufs ;
89
89
private final Http2Connection connection ;
90
90
private final Http2FrameListener listener ;
91
91
private final DefaultHttp2FrameReader reader ;
92
92
private CountDownLatch latch ;
93
93
94
- FrameAdapter (Http2FrameListener listener , CountDownLatch latch , boolean copyBufs ) {
95
- this (null , listener , latch , copyBufs );
94
+ FrameAdapter (Http2FrameListener listener , CountDownLatch latch , boolean retainBufs ) {
95
+ this (null , listener , latch , retainBufs );
96
96
}
97
97
98
- FrameAdapter (Http2Connection connection , Http2FrameListener listener , CountDownLatch latch , boolean copyBufs ) {
99
- this (connection , new DefaultHttp2FrameReader (), listener , latch , copyBufs );
98
+ FrameAdapter (Http2Connection connection , Http2FrameListener listener , CountDownLatch latch ,
99
+ boolean retainBufs ) {
100
+ this (connection , new DefaultHttp2FrameReader (), listener , latch , retainBufs );
100
101
}
101
102
102
103
FrameAdapter (Http2Connection connection , DefaultHttp2FrameReader reader , Http2FrameListener listener ,
103
- CountDownLatch latch , boolean copyBufs ) {
104
+ CountDownLatch latch , boolean retainBufs ) {
104
105
this .connection = connection ;
105
106
this .listener = listener ;
106
107
this .reader = reader ;
107
- this .copyBufs = copyBufs ;
108
+ this .retainBufs = retainBufs ;
108
109
latch (latch );
109
110
}
110
111
@@ -149,7 +150,7 @@ protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) t
149
150
public void onDataRead (ChannelHandlerContext ctx , int streamId , ByteBuf data , int padding ,
150
151
boolean endOfStream ) throws Http2Exception {
151
152
Http2Stream stream = getOrCreateStream (streamId , endOfStream );
152
- listener .onDataRead (ctx , streamId , copyBufs ? data .copy () : data , padding , endOfStream );
153
+ listener .onDataRead (ctx , streamId , retainBufs ? data .retain () : data , padding , endOfStream );
153
154
if (endOfStream ) {
154
155
closeStream (stream , true );
155
156
}
@@ -217,13 +218,13 @@ public void onSettingsRead(ChannelHandlerContext ctx, Http2Settings settings) th
217
218
218
219
@ Override
219
220
public void onPingRead (ChannelHandlerContext ctx , ByteBuf data ) throws Http2Exception {
220
- listener .onPingRead (ctx , copyBufs ? data .copy () : data );
221
+ listener .onPingRead (ctx , retainBufs ? data .retain () : data );
221
222
latch .countDown ();
222
223
}
223
224
224
225
@ Override
225
226
public void onPingAckRead (ChannelHandlerContext ctx , ByteBuf data ) throws Http2Exception {
226
- listener .onPingAckRead (ctx , copyBufs ? data .copy () : data );
227
+ listener .onPingAckRead (ctx , retainBufs ? data .retain () : data );
227
228
latch .countDown ();
228
229
}
229
230
@@ -238,7 +239,7 @@ public void onPushPromiseRead(ChannelHandlerContext ctx, int streamId, int promi
238
239
@ Override
239
240
public void onGoAwayRead (ChannelHandlerContext ctx , int lastStreamId , long errorCode , ByteBuf debugData )
240
241
throws Http2Exception {
241
- listener .onGoAwayRead (ctx , lastStreamId , errorCode , copyBufs ? debugData .copy () : debugData );
242
+ listener .onGoAwayRead (ctx , lastStreamId , errorCode , retainBufs ? debugData .retain () : debugData );
242
243
latch .countDown ();
243
244
}
244
245
@@ -290,7 +291,7 @@ public void dataLatch(CountDownLatch latch) {
290
291
@ Override
291
292
public void onDataRead (ChannelHandlerContext ctx , int streamId , ByteBuf data , int padding , boolean endOfStream )
292
293
throws Http2Exception {
293
- listener .onDataRead (ctx , streamId , data .copy (), padding , endOfStream );
294
+ listener .onDataRead (ctx , streamId , data .retain (), padding , endOfStream );
294
295
messageLatch .countDown ();
295
296
if (dataLatch != null ) {
296
297
for (int i = 0 ; i < data .readableBytes (); ++i ) {
@@ -340,13 +341,13 @@ public void onSettingsRead(ChannelHandlerContext ctx, Http2Settings settings) th
340
341
341
342
@ Override
342
343
public void onPingRead (ChannelHandlerContext ctx , ByteBuf data ) throws Http2Exception {
343
- listener .onPingRead (ctx , data .copy ());
344
+ listener .onPingRead (ctx , data .retain ());
344
345
messageLatch .countDown ();
345
346
}
346
347
347
348
@ Override
348
349
public void onPingAckRead (ChannelHandlerContext ctx , ByteBuf data ) throws Http2Exception {
349
- listener .onPingAckRead (ctx , data .copy ());
350
+ listener .onPingAckRead (ctx , data .retain ());
350
351
messageLatch .countDown ();
351
352
}
352
353
@@ -360,7 +361,7 @@ public void onPushPromiseRead(ChannelHandlerContext ctx, int streamId, int promi
360
361
@ Override
361
362
public void onGoAwayRead (ChannelHandlerContext ctx , int lastStreamId , long errorCode , ByteBuf debugData )
362
363
throws Http2Exception {
363
- listener .onGoAwayRead (ctx , lastStreamId , errorCode , debugData .copy ());
364
+ listener .onGoAwayRead (ctx , lastStreamId , errorCode , debugData .retain ());
364
365
messageLatch .countDown ();
365
366
}
366
367
0 commit comments