Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite43da76

Browse files
committed
NettyReactiveStreamsBody shouldn't assume ByteBuffer has an array without offset and partial length
1 parent3abe37b commite43da76

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

‎client/src/main/java/org/asynchttpclient/netty/request/body/NettyReactiveStreamsBody.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public void onSubscribe(Subscription s) {
8181
}
8282
@Override
8383
publicvoidonNext(ByteBuffert) {
84-
ByteBufbuffer =Unpooled.wrappedBuffer(t.array());
84+
ByteBufbuffer =Unpooled.wrappedBuffer(t);
8585
HttpContentcontent =newDefaultHttpContent(buffer);
8686
subscriber.onNext(content);
8787
}

‎client/src/test/java/org/asynchttpclient/reactivestreams/ReactiveStreamsTest.java‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,15 @@
1212
*/
1313
packageorg.asynchttpclient.reactivestreams;
1414

15-
importstaticorg.asynchttpclient.Dsl.*;
16-
importstaticorg.asynchttpclient.test.TestUtils.*;
1715
importstaticio.netty.handler.codec.http.HttpHeaderNames.*;
16+
importstaticorg.asynchttpclient.Dsl.*;
17+
importstaticorg.asynchttpclient.test.TestUtils.LARGE_IMAGE_BYTES;
1818
importstaticorg.testng.Assert.assertEquals;
1919
importio.netty.handler.codec.http.HttpHeaders;
2020

2121
importjava.io.ByteArrayOutputStream;
2222
importjava.nio.ByteBuffer;
2323
importjava.util.ArrayList;
24-
importjava.util.Arrays;
2524
importjava.util.Collections;
2625
importjava.util.Iterator;
2726
importjava.util.List;
@@ -359,10 +358,10 @@ public boolean hasNext() {
359358

360359
@Override
361360
publicByteBuffernext() {
362-
intnewIndex =Math.min(currentIndex +chunkSize,payload.length);
363-
byte[]bytesInElement =Arrays.copyOfRange(payload,currentIndex,newIndex);
364-
currentIndex=newIndex;
365-
returnByteBuffer.wrap(bytesInElement);
361+
intthisCurrentIndex =currentIndex;
362+
intlength =Math.min(chunkSize,payload.length -thisCurrentIndex);
363+
currentIndex+=length;
364+
returnByteBuffer.wrap(payload,thisCurrentIndex,length);
366365
}
367366

368367
@Override

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp