http-client-branch: review comment: Utils::accumulateBuffers sets a wrong limit http-client-branch
authordfuchs
Wed, 06 Dec 2017 10:33:27 +0000
branchhttp-client-branch
changeset 55958 24e637188a68
parent 55957 37126be36316
child 55959 7fd1a84f4fae
child 55962 35376c843df1
http-client-branch: review comment: Utils::accumulateBuffers sets a wrong limit
src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/common/Utils.java
--- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/common/Utils.java	Tue Dec 05 22:44:33 2017 +0300
+++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/common/Utils.java	Wed Dec 06 10:33:27 2017 +0000
@@ -344,14 +344,14 @@
                 continue;
             }
 
-            ByteBuffer lastBuffer = currentList.get(currentList.size() - 1);
+            ByteBuffer lastBuffer = currentList.get(listSize - 1);
             int freeSpace = lastBuffer.capacity() - lastBuffer.limit();
             if (remaining <= COPY_THRESHOLD && freeSpace >= remaining) {
                 // append the new data to the unused space in the last buffer
                 int position = lastBuffer.position();
                 int limit = lastBuffer.limit();
                 lastBuffer.position(limit);
-                lastBuffer.limit(limit + bufferToAdd.limit());
+                lastBuffer.limit(limit + remaining);
                 lastBuffer.put(bufferToAdd);
                 lastBuffer.position(position);
             } else {