From: Robert Varga Date: Fri, 29 Jul 2016 19:41:17 +0000 (+0200) Subject: Make deserializeNormalizedNode more obvious X-Git-Tag: release/boron~35 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=b0b6c5a1e28fba052f4dabfd7b8ec73d3468c9d9;hp=744080c6e16bd2ba675b7b526b900aa6ee68bb90 Make deserializeNormalizedNode more obvious Performing a direct return makes the code flow more obvious, notably the fact that a null node may only be received in case of new serialization. Change-Id: Ib10c23d5990ca4452914b7f81647fd67b84863d2 Signed-off-by: Robert Varga --- diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/SerializationUtils.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/SerializationUtils.java index 5f84f54b74..1cb436d5a3 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/SerializationUtils.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/SerializationUtils.java @@ -114,22 +114,19 @@ public final class SerializationUtils { } public static NormalizedNode deserializeNormalizedNode(byte [] bytes) { - NormalizedNode node = null; try { - node = tryDeserializeNormalizedNode(new DataInputStream(new ByteArrayInputStream(bytes))); + return tryDeserializeNormalizedNode(new DataInputStream(new ByteArrayInputStream(bytes))); } catch(InvalidNormalizedNodeStreamException e) { // Probably from legacy protobuf serialization - try that. try { NormalizedNodeMessages.Node serializedNode = NormalizedNodeMessages.Node.parseFrom(bytes); - node = new NormalizedNodeToNodeCodec(null).decode(serializedNode); + return new NormalizedNodeToNodeCodec(null).decode(serializedNode); } catch (InvalidProtocolBufferException e2) { throw new IllegalArgumentException("Error deserializing NormalizedNode", e); } } catch (IOException e) { throw new IllegalArgumentException("Error deserializing NormalizedNode", e); } - - return node; } public static byte [] serializeNormalizedNode(NormalizedNode node) {