hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject [1/2] httpcomponents-core git commit: Bugfix: non-blocking FrameOutputBuffer does not reset its internal buffer in case of a I/O error
Date Tue, 21 Nov 2017 14:29:51 GMT
Repository: httpcomponents-core
Updated Branches:
  refs/heads/master ed5e82160 -> 1c3a57129


Bugfix: non-blocking FrameOutputBuffer does not reset its internal buffer in case of a I/O
error


Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/commit/f541cad9
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/tree/f541cad9
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/diff/f541cad9

Branch: refs/heads/master
Commit: f541cad905bc09629611952e5cbdb2e050f8d502
Parents: ed5e821
Author: Oleg Kalnichevski <olegk@apache.org>
Authored: Tue Nov 21 14:07:17 2017 +0100
Committer: Oleg Kalnichevski <olegk@apache.org>
Committed: Tue Nov 21 14:07:17 2017 +0100

----------------------------------------------------------------------
 .../core5/http2/impl/nio/FrameOutputBuffer.java | 23 ++++++++------------
 1 file changed, 9 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/f541cad9/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/FrameOutputBuffer.java
----------------------------------------------------------------------
diff --git a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/FrameOutputBuffer.java
b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/FrameOutputBuffer.java
index d6ae7fe..54f9982 100644
--- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/FrameOutputBuffer.java
+++ b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/FrameOutputBuffer.java
@@ -62,13 +62,6 @@ public final class FrameOutputBuffer {
         this(new BasicH2TransportMetrics(), maxFramePayloadSize);
     }
 
-    private void writeToChannel(final WritableByteChannel channel, final ByteBuffer src)
throws IOException {
-        final int bytesWritten = channel.write(src);
-        if (bytesWritten > 0) {
-            metrics.incrementBytesTransferred(bytesWritten);
-        }
-    }
-
     public void write(final RawFrame frame, final WritableByteChannel channel) throws IOException
{
         Args.notNull(frame, "Frame");
 
@@ -94,11 +87,7 @@ public final class FrameOutputBuffer {
             }
         }
 
-        if (buffer.position() > 0) {
-            buffer.flip();
-            writeToChannel(channel, buffer);
-            buffer.compact();
-        }
+        flush(channel);
 
         metrics.incrementFramesTransferred();
     }
@@ -106,8 +95,14 @@ public final class FrameOutputBuffer {
     public void flush(final WritableByteChannel channel) throws IOException {
         if (buffer.position() > 0) {
             buffer.flip();
-            writeToChannel(channel, buffer);
-            buffer.compact();
+            try {
+                final int bytesWritten = channel.write(buffer);
+                if (bytesWritten > 0) {
+                    metrics.incrementBytesTransferred(bytesWritten);
+                }
+            } finally {
+                buffer.compact();
+            }
         }
     }
 


Mime
View raw message