Create empty match only once 26/42126/2
authorAndrej Leitner <anleitne@cisco.com>
Wed, 20 Jul 2016 08:14:56 +0000 (10:14 +0200)
committerAndrej Leitner <anleitne@cisco.com>
Wed, 20 Jul 2016 08:40:29 +0000 (10:40 +0200)
Change-Id: I206a588303c563d42c173cf2062501c92159dcc4
Signed-off-by: Andrej Leitner <anleitne@cisco.com>
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/registry/flow/FlowRegistryKeyFactory.java

index c5acfa0b76b87b56f24c8a7d2dcd1847ecc8be13..420064633eb83b1c08ca0ab99c07f3c393b73891 100644 (file)
@@ -36,12 +36,13 @@ public class FlowRegistryKeyFactory {
         private final int priority;
         private final BigInteger cookie;
         private final Match match;
+        private static final Match EMPTY_MATCH = new MatchBuilder().build();
 
         public FlowRegistryKeyDto(final Flow flow) {
             //TODO: mandatory flow input values (or default values) should be specified via yang model
             tableId = Preconditions.checkNotNull(flow.getTableId(), "flow tableId must not be null");
             priority = MoreObjects.firstNonNull(flow.getPriority(), OFConstants.DEFAULT_FLOW_PRIORITY);
-            match = flow.getMatch()==null? new MatchBuilder().build(): flow.getMatch();
+            match = flow.getMatch()==null ? EMPTY_MATCH : flow.getMatch();
             cookie = MoreObjects.firstNonNull(flow.getCookie(), OFConstants.DEFAULT_FLOW_COOKIE).getValue();
         }