THRIFT-2402: byte count of FrameBuffer in AWAITING_CLOSE state is not subtracted...
authorjfarrell <jfarrell@apache.org>
Fri, 4 Apr 2014 17:09:32 +0000 (13:09 -0400)
committerjfarrell <jfarrell@apache.org>
Fri, 4 Apr 2014 17:09:32 +0000 (13:09 -0400)
Client: java
Patch: jfarrell

Addresses issue where changeSelectInterests would cause close() to occur in the AWAITING_CLOSE state and readBufferBytesAllocated was never called

lib/java/src/org/apache/thrift/server/AbstractNonblockingServer.java

index 80da6ca..fd49d48 100644 (file)
@@ -455,7 +455,9 @@ public abstract class AbstractNonblockingServer extends TServer {
     public void close() {
       // if we're being closed due to an error, we might have allocated a
       // buffer that we need to subtract for our memory accounting.
-      if (state_ == FrameBufferState.READING_FRAME || state_ == FrameBufferState.READ_FRAME_COMPLETE) {
+      if (state_ == FrameBufferState.READING_FRAME || 
+          state_ == FrameBufferState.READ_FRAME_COMPLETE ||
+          state_ == FrameBufferState.AWAITING_CLOSE) {
         readBufferBytesAllocated.addAndGet(-buffer_.array().length);
       }
       trans_.close();