You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@heron.apache.org by nl...@apache.org on 2018/09/19 22:01:32 UTC

[incubator-heron] branch master updated: Revert "refactor JavaSerializer for closing input/output stream"

This is an automated email from the ASF dual-hosted git repository.

nlu90 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-heron.git


The following commit(s) were added to refs/heads/master by this push:
     new 72509b9  Revert "refactor JavaSerializer for closing input/output stream"
72509b9 is described below

commit 72509b91f1744a1d85f5982d5c69741120409eb4
Author: Neng Lu <nl...@twitter.com>
AuthorDate: Wed Sep 19 15:00:57 2018 -0700

    Revert "refactor JavaSerializer for closing input/output stream"
    
    This reverts commit db3f1c406c7ff73113e2c469b44636baee1eb77f.
---
 .../apache/heron/api/serializer/JavaSerializer.java  | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/heron/api/src/java/org/apache/heron/api/serializer/JavaSerializer.java b/heron/api/src/java/org/apache/heron/api/serializer/JavaSerializer.java
index cb942db..75a1fba 100644
--- a/heron/api/src/java/org/apache/heron/api/serializer/JavaSerializer.java
+++ b/heron/api/src/java/org/apache/heron/api/serializer/JavaSerializer.java
@@ -34,23 +34,25 @@ public class JavaSerializer implements IPluggableSerializer {
 
   @Override
   public byte[] serialize(Object object) {
-    try (ByteArrayOutputStream bos = new ByteArrayOutputStream();
-         ObjectOutputStream oos = new ObjectOutputStream(bos)) {
+    ByteArrayOutputStream bos = new ByteArrayOutputStream();
+    try {
+      ObjectOutputStream oos = new ObjectOutputStream(bos);
       oos.writeObject(object);
       oos.flush();
-      return bos.toByteArray();
-    } catch (IOException ex) {
-      throw new RuntimeException("Failed to serialize object: " + object.toString(), ex);
+    } catch (IOException e) {
+      throw new RuntimeException("Failed to serialize object: " + object.toString(), e);
     }
+    return bos.toByteArray();
   }
 
   @Override
   public Object deserialize(byte[] input) {
-    try (ByteArrayInputStream bis = new ByteArrayInputStream(input);
-          ObjectInputStream ois = new ObjectInputStream(bis)) {
+    ByteArrayInputStream bis = new ByteArrayInputStream(input);
+    try {
+      ObjectInputStream ois = new ObjectInputStream(bis);
       return ois.readObject();
-    } catch (IOException | ClassNotFoundException ex) {
-      throw new RuntimeException(ex);
+    } catch (IOException | ClassNotFoundException e) {
+      throw new RuntimeException(e);
     }
   }
 }