Add assertion around QueryDataBatch release to ensure that we're not releasing 
the buffers twice.


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

Branch: refs/heads/master
Commit: 982621561fec3029bffb7a27bd71d4cc3340000e
Parents: a5a1aa6
Author: Jacques Nadeau <[email protected]>
Authored: Fri Nov 6 19:08:30 2015 -0800
Committer: Jacques Nadeau <[email protected]>
Committed: Fri Nov 6 21:41:07 2015 -0800

----------------------------------------------------------------------
 .../java/org/apache/drill/exec/rpc/user/QueryDataBatch.java   | 7 +++++++
 1 file changed, 7 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/98262156/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/user/QueryDataBatch.java
----------------------------------------------------------------------
diff --git 
a/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/user/QueryDataBatch.java
 
b/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/user/QueryDataBatch.java
index f2ef414..e2413a9 100644
--- 
a/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/user/QueryDataBatch.java
+++ 
b/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/user/QueryDataBatch.java
@@ -19,6 +19,8 @@ package org.apache.drill.exec.rpc.user;
 
 import io.netty.buffer.DrillBuf;
 
+import java.util.concurrent.atomic.AtomicBoolean;
+
 import org.apache.drill.exec.proto.UserBitShared.QueryData;
 
 public class QueryDataBatch {
@@ -26,6 +28,7 @@ public class QueryDataBatch {
 
   private final QueryData header;
   private final DrillBuf data;
+  private final AtomicBoolean released = new AtomicBoolean(false);
 
   public QueryDataBatch(QueryData header, DrillBuf data) {
     // logger.debug("New Result Batch with header {} and data {}", header, 
data);
@@ -49,6 +52,10 @@ public class QueryDataBatch {
   }
 
   public void release() {
+    if (!released.compareAndSet(false, true)) {
+      throw new IllegalStateException("QueryDataBatch was released twice.");
+    }
+
     if (data != null) {
       data.release(1);
     }

Reply via email to