Make deserializeNormalizedNode more obvious 03/42803/2
authorRobert Varga <rovarga@cisco.com>
Fri, 29 Jul 2016 19:41:17 +0000 (21:41 +0200)
committerTom Pantelis <tpanteli@brocade.com>
Sat, 30 Jul 2016 09:11:48 +0000 (09:11 +0000)
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 <rovarga@cisco.com>
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/SerializationUtils.java

index 5f84f54..1cb436d 100644 (file)
@@ -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) {