Escape IOExceptions in the AvroClassHierarchySerializer

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

Branch: refs/heads/REEF-395
Commit: ba431c4566226b03380b44bf340814cacc8fd927
Parents: d040261
Author: Yunseong Lee <[email protected]>
Authored: Tue Jun 23 22:12:24 2015 +0900
Committer: Yunseong Lee <[email protected]>
Committed: Tue Jun 23 22:12:24 2015 +0900

----------------------------------------------------------------------
 .../formats/AvroClassHierarchySerializer.java   | 24 +++++---------------
 1 file changed, 6 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/ba431c45/lang/java/reef-tang/tang/src/main/java/org/apache/reef/tang/formats/AvroClassHierarchySerializer.java
----------------------------------------------------------------------
diff --git 
a/lang/java/reef-tang/tang/src/main/java/org/apache/reef/tang/formats/AvroClassHierarchySerializer.java
 
b/lang/java/reef-tang/tang/src/main/java/org/apache/reef/tang/formats/AvroClassHierarchySerializer.java
index 8dbc0af..b6acd29 100644
--- 
a/lang/java/reef-tang/tang/src/main/java/org/apache/reef/tang/formats/AvroClassHierarchySerializer.java
+++ 
b/lang/java/reef-tang/tang/src/main/java/org/apache/reef/tang/formats/AvroClassHierarchySerializer.java
@@ -203,8 +203,6 @@ public final class AvroClassHierarchySerializer implements 
ClassHierarchySeriali
       requestWriter.write(toAvro(classHierarchy), encoder);
       encoder.flush();
       return out.toByteArray();
-    } catch (IOException e) {
-      throw new RuntimeException(e);
     }
   }
 
@@ -217,8 +215,6 @@ public final class AvroClassHierarchySerializer implements 
ClassHierarchySeriali
       encoder.flush();
       out.flush();
       return out.toString(JSON_CHARSET);
-    } catch (IOException e) {
-      throw new RuntimeException(e);
     }
   }
 
@@ -241,24 +237,16 @@ public final class AvroClassHierarchySerializer 
implements ClassHierarchySeriali
 
   @Override
   public ClassHierarchy fromByteArray(final byte[] theBytes) throws 
IOException {
-    try {
-      final BinaryDecoder decoder = 
DecoderFactory.get().binaryDecoder(theBytes, null);
-      final SpecificDatumReader<AvroNode> reader = new 
SpecificDatumReader<>(AvroNode.class);
-      return fromAvro(reader.read(null, decoder));
-    } catch (IOException e) {
-      throw new RuntimeException(e);
-    }
+    final BinaryDecoder decoder = DecoderFactory.get().binaryDecoder(theBytes, 
null);
+    final SpecificDatumReader<AvroNode> reader = new 
SpecificDatumReader<>(AvroNode.class);
+    return fromAvro(reader.read(null, decoder));
   }
 
   @Override
   public ClassHierarchy fromString(final String theString) throws IOException {
-    try {
-      final JsonDecoder decoder = 
DecoderFactory.get().jsonDecoder(AvroNode.getClassSchema(), theString);
-      final SpecificDatumReader<AvroNode> reader = new 
SpecificDatumReader<>(AvroNode.class);
-      return fromAvro(reader.read(null, decoder));
-    } catch (IOException e) {
-      throw new RuntimeException(e);
-    }
+    final JsonDecoder decoder = 
DecoderFactory.get().jsonDecoder(AvroNode.getClassSchema(), theString);
+    final SpecificDatumReader<AvroNode> reader = new 
SpecificDatumReader<>(AvroNode.class);
+    return fromAvro(reader.read(null, decoder));
   }
 
   @Override

Reply via email to