tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1847310 - /tomcat/trunk/java/org/apache/coyote/http2/Stream.java
Date Fri, 23 Nov 2018 19:50:33 GMT
Author: markt
Date: Fri Nov 23 19:50:33 2018
New Revision: 1847310

URL: http://svn.apache.org/viewvc?rev=1847310&view=rev
Log:
Simplify code

Modified:
    tomcat/trunk/java/org/apache/coyote/http2/Stream.java

Modified: tomcat/trunk/java/org/apache/coyote/http2/Stream.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http2/Stream.java?rev=1847310&r1=1847309&r2=1847310&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http2/Stream.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http2/Stream.java Fri Nov 23 19:50:33 2018
@@ -733,7 +733,8 @@ class Stream extends AbstractStream impl
                 throw new IllegalStateException(
                         sm.getString("stream.closed", getConnectionId(), getIdentifier()));
             }
-            int totalThisTime = 0;
+            // chunk is always fully written
+            int result = chunk.remaining();
             if (writeBuffer.isEmpty()) {
                 int chunkLimit = chunk.limit();
                 while (chunk.remaining() > 0) {
@@ -741,23 +742,20 @@ class Stream extends AbstractStream impl
                     chunk.limit(chunk.position() + thisTime);
                     buffer.put(chunk);
                     chunk.limit(chunkLimit);
-                    totalThisTime += thisTime;
                     if (chunk.remaining() > 0 && !buffer.hasRemaining()) {
                         // Only flush if we have more data to write and the buffer
                         // is full
                         if (flush(true, coyoteResponse.getWriteListener() == null)) {
-                            totalThisTime += chunk.remaining();
                             writeBuffer.add(chunk);
                             break;
                         }
                     }
                 }
             } else {
-                totalThisTime = chunk.remaining();
                 writeBuffer.add(chunk);
             }
-            written += totalThisTime;
-            return totalThisTime;
+            written += result;
+            return result;
         }
 
         final synchronized boolean flush(boolean block) throws IOException {



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message