You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by kl...@apache.org on 2017/05/23 21:46:57 UTC

geode git commit: Do NOT close HeapDataOutputStream that is passed to Part

Repository: geode
Updated Branches:
  refs/heads/feature/GEODE-2632-17 fd84df29b -> 012b47563


Do NOT close HeapDataOutputStream that is passed to Part


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

Branch: refs/heads/feature/GEODE-2632-17
Commit: 012b47563bd54a6ba0956296f62fadb292cd4dfc
Parents: fd84df2
Author: Kirk Lund <kl...@apache.org>
Authored: Tue May 23 14:46:34 2017 -0700
Committer: Kirk Lund <kl...@apache.org>
Committed: Tue May 23 14:46:34 2017 -0700

----------------------------------------------------------------------
 .../internal/cache/tier/sockets/Message.java    | 36 ++++++++------------
 1 file changed, 15 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/012b4756/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/Message.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/Message.java b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/Message.java
index 2ac6fea..de3017b 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/Message.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/Message.java
@@ -297,14 +297,11 @@ public class Message {
         }
       }
       part.setPartState(bytes, false);
+
     } else {
-      HeapDataOutputStream hdos = new HeapDataOutputStream(str);
-      try {
-        this.messageModified = true;
-        part.setPartState(hdos, false);
-      } finally {
-        close(hdos);
-      }
+      // do NOT close the HeapDataOutputStream
+      this.messageModified = true;
+      part.setPartState(new HeapDataOutputStream(str), false);
     }
     this.currentPart++;
   }
@@ -380,20 +377,18 @@ public class Message {
       v = null;
     }
 
-    // create the HDOS with a flag telling it that it can keep any byte[] or ByteBuffers/ByteSources
-    // passed to it.
+    // Create the HDOS with a flag telling it that it can keep any byte[] or ByteBuffers/ByteSources
+    // passed to it. Do NOT close the HeapDataOutputStream!
     HeapDataOutputStream hdos = new HeapDataOutputStream(this.chunkSize, v, true);
     try {
       BlobHelper.serializeTo(o, hdos);
-      this.messageModified = true;
-      Part part = this.partsList[this.currentPart];
-      part.setPartState(hdos, true);
-      this.currentPart++;
     } catch (IOException ex) {
       throw new SerializationException("failed serializing object", ex);
-    } finally {
-      close(hdos);
     }
+    this.messageModified = true;
+    Part part = this.partsList[this.currentPart];
+    part.setPartState(hdos, true);
+    this.currentPart++;
   }
 
   private void serializeAndAddPart(Object o, boolean zipValues) {
@@ -406,18 +401,17 @@ public class Message {
       v = null;
     }
 
+    // do NOT close the HeapDataOutputStream
     HeapDataOutputStream hdos = new HeapDataOutputStream(this.chunkSize, v);
     try {
       BlobHelper.serializeTo(o, hdos);
-      this.messageModified = true;
-      Part part = this.partsList[this.currentPart];
-      part.setPartState(hdos, true);
-      this.currentPart++;
     } catch (IOException ex) {
       throw new SerializationException("failed serializing object", ex);
-    } finally {
-      close(hdos);
     }
+    this.messageModified = true;
+    Part part = this.partsList[this.currentPart];
+    part.setPartState(hdos, true);
+    this.currentPart++;
   }
 
   public void addIntPart(int v) {