From b0b6c5a1e28fba052f4dabfd7b8ec73d3468c9d9 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Fri, 29 Jul 2016 21:41:17 +0200 Subject: [PATCH 1/1] 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 --- .../cluster/datastore/utils/SerializationUtils.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) 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) { -- 2.36.6