[maven-surefire] branch maven2surefire-jvm-communication updated: buffer flip

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[maven-surefire] branch maven2surefire-jvm-communication updated: buffer flip

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

tibordigana pushed a commit to branch maven2surefire-jvm-communication
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git


The following commit(s) were added to refs/heads/maven2surefire-jvm-communication by this push:
     new cc59f07  buffer flip
cc59f07 is described below

commit cc59f076dd2cb81a30ae65457ebb48e2a4ca3adc
Author: tibordigana <[hidden email]>
AuthorDate: Sat Nov 9 03:50:32 2019 +0100

    buffer flip
---
 .../plugin/surefire/extensions/NetworkingProcessExecutor.java  | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/extensions/NetworkingProcessExecutor.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/extensions/NetworkingProcessExecutor.java
index 8031413..c04f972 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/extensions/NetworkingProcessExecutor.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/extensions/NetworkingProcessExecutor.java
@@ -115,7 +115,6 @@ final class NetworkingProcessExecutor implements ExecutableCommandline
                     {
                         try
                         {
-
                             for ( Command cmd; ( cmd = commands.readNextCommand() ) != null;  )
                             {
                                 MasterProcessCommand cmdType = cmd.getCommandType();
@@ -164,7 +163,6 @@ final class NetworkingProcessExecutor implements ExecutableCommandline
         return new InputStream()
         {
             private final ByteBuffer bb = ByteBuffer.allocate( 64 * 1024 );
-            private int read;
             private boolean closed;
 
             @Override
@@ -177,16 +175,16 @@ final class NetworkingProcessExecutor implements ExecutableCommandline
 
                 try
                 {
-                    if ( read == 0 )
+                    if ( !bb.hasRemaining() )
                     {
                         bb.clear();
-                        read = client.read( bb ).get();
-                        if ( read == 0 )
+                        if ( client.read( bb ).get() == 0 )
                         {
+                            closed = true;
                             return -1;
                         }
+                        bb.flip();
                     }
-                    read--;
                     return bb.get();
                 }
                 catch ( InterruptedException e )