You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2019/03/07 10:36:40 UTC

[httpcomponents-client] branch bug-fixes updated: Bug fix: Fixed broken data generation logic in AsyncRandomHandler (affects test code only)

This is an automated email from the ASF dual-hosted git repository.

olegk pushed a commit to branch bug-fixes
in repository https://gitbox.apache.org/repos/asf/httpcomponents-client.git


The following commit(s) were added to refs/heads/bug-fixes by this push:
     new 7146a36  Bug fix: Fixed broken data generation logic in AsyncRandomHandler (affects test code only)
7146a36 is described below

commit 7146a36f878235c2e6625b341f69d86aa487e094
Author: Oleg Kalnichevski <ol...@apache.org>
AuthorDate: Thu Mar 7 11:32:16 2019 +0100

    Bug fix: Fixed broken data generation logic in AsyncRandomHandler (affects test code only)
---
 .../apache/hc/client5/testing/async/AsyncRandomHandler.java    | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/httpclient5-testing/src/main/java/org/apache/hc/client5/testing/async/AsyncRandomHandler.java b/httpclient5-testing/src/main/java/org/apache/hc/client5/testing/async/AsyncRandomHandler.java
index 07a5cf5..844ea43 100644
--- a/httpclient5-testing/src/main/java/org/apache/hc/client5/testing/async/AsyncRandomHandler.java
+++ b/httpclient5-testing/src/main/java/org/apache/hc/client5/testing/async/AsyncRandomHandler.java
@@ -197,13 +197,13 @@ public class AsyncRandomHandler implements AsyncServerExchangeHandler {
                 final byte b = RANGE[(int) (Math.random() * RANGE.length)];
                 buffer.put(b);
             }
+            remaining -= chunk;
+
             buffer.flip();
-            final int bytesWritten = channel.write(buffer);
-            if (bytesWritten > 0) {
-                remaining -= bytesWritten;
-            }
+            channel.write(buffer);
             buffer.compact();
-            if (remaining <= 0) {
+
+            if (remaining <= 0 && buffer.position() == 0) {
                 channel.endStream();
             }
         }