Fix double translation of messages. 37/3937/2
authorEd Warnicke <eaw@cisco.com>
Thu, 26 Dec 2013 18:21:56 +0000 (10:21 -0800)
committerEd Warnicke <eaw@cisco.com>
Fri, 27 Dec 2013 17:17:07 +0000 (09:17 -0800)
Also, return Collections.emptyList() if we do not have a
result from translation rather than null.

Change-Id: I64e014c8cdbe794570e5f9f525574789fd53a5da
Signed-off-by: Ed Warnicke <eaw@cisco.com>
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/translator/ErrorTranslator.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/translator/ExperimenterTranslator.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/translator/FlowRemovedTranslator.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/translator/MultiPartMessageDescToNodeUpdatedTranslator.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/translator/MultiPartReplyPortToNodeConnectorUpdatedTranslator.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/translator/MultipartReplyTableFeaturesToTableUpdatedTranslator.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/translator/PacketInTranslator.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/translator/PortStatusMessageToNodeConnectorUpdatedTranslator.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/queue/TicketProcessorFactory.java

index bec562615df38ce94a9cbed97c1660314e1e8e96..565692e0acefc8aaa3feb84e8b2a9b0cac6b9885 100644 (file)
@@ -1,6 +1,7 @@
 package org.opendaylight.openflowplugin.openflow.md.core.translator;
 
 import java.math.BigInteger;
+import java.util.Collections;
 import java.util.List;
 import java.util.concurrent.CopyOnWriteArrayList;
 
@@ -54,7 +55,7 @@ public class ErrorTranslator implements IMDMessageTranslator<OfHeader, List<Data
             return list;
         } else {
             LOG.error("Message is not of Error Message ");
-            return null;
+            return Collections.emptyList();
         }
     }
 
index af85a5f07900890ea9f7573ba13a03c361e24997..eea892e372ff6e59b79878ac10b53d41554f17e2 100644 (file)
@@ -1,6 +1,7 @@
 package org.opendaylight.openflowplugin.openflow.md.core.translator;
 
 import java.math.BigInteger;
+import java.util.Collections;
 import java.util.List;
 import java.util.concurrent.CopyOnWriteArrayList;
 
@@ -52,7 +53,7 @@ public class ExperimenterTranslator implements IMDMessageTranslator<OfHeader, Li
                        return list;
                }else {
                        LOG.error( "Message is not of Experimenter Error Message " ) ;
-                       return null;
+                       return Collections.emptyList();
                }
        }
 
index 300e21afa274d8ee668b91e8ead63c2b401cb43d..b45edba0f154e228d045c3d2b0e9dbd6da2416e3 100644 (file)
@@ -1,6 +1,7 @@
 package org.opendaylight.openflowplugin.openflow.md.core.translator;
 
 import java.math.BigInteger;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -155,7 +156,7 @@ public class FlowRemovedTranslator implements IMDMessageTranslator<OfHeader, Lis
             return list;
         } else {
             LOG.error("Message is not a flow removed message ");
-            return null;
+            return Collections.emptyList();
         }
     }
 
index 3fa527a782bb1ab6048bded28c8c2d06d3dc8eeb..6390c06852c55bef29a5b4384a3bc36b1d0f2e8c 100644 (file)
@@ -1,6 +1,7 @@
 package org.opendaylight.openflowplugin.openflow.md.core.translator;
 
 import java.math.BigInteger;
+import java.util.Collections;
 import java.util.List;
 import java.util.concurrent.CopyOnWriteArrayList;
 
@@ -46,7 +47,7 @@ public class MultiPartMessageDescToNodeUpdatedTranslator implements IMDMessageTr
             list.add(nodeUpdated);
             return list;
         } else {
-            return null;
+            return Collections.emptyList();
         }
     }
 
index 2b019132ddc1e36ce9b25dda436aaccabafa1e5d..e79bbc7cef0fc933d5f7d59d44976e0e5424b3c1 100644 (file)
@@ -1,6 +1,7 @@
 package org.opendaylight.openflowplugin.openflow.md.core.translator;
 
 import java.math.BigInteger;
+import java.util.Collections;
 import java.util.List;
 import java.util.concurrent.CopyOnWriteArrayList;
 
@@ -57,7 +58,7 @@ public class MultiPartReplyPortToNodeConnectorUpdatedTranslator implements IMDMe
             }
             return list;
         } else {
-            return null;
+            return Collections.emptyList();
         }
     }
 
index 7cdb682a59069ce9a4a0a44f69437087843969c5..219cb4916d13c44e271da26edfdfedace51043ea 100644 (file)
@@ -1,6 +1,7 @@
 package org.opendaylight.openflowplugin.openflow.md.core.translator;
 
 import java.math.BigInteger;
+import java.util.Collections;
 import java.util.List;
 import java.util.concurrent.CopyOnWriteArrayList;
 
@@ -52,7 +53,7 @@ public class MultipartReplyTableFeaturesToTableUpdatedTranslator implements
             return listDataObject ;
             
                }
-               return null;
+               return Collections.emptyList();
                
        }
        
index a93567d70e94a3879dd7e595048c5700188e6de1..b7d5f7a00bd6f955b13f95df101e1467b51c2cd5 100644 (file)
@@ -1,6 +1,7 @@
 package org.opendaylight.openflowplugin.openflow.md.core.translator;
 
 import java.math.BigInteger;
+import java.util.Collections;
 import java.util.List;
 import java.util.concurrent.CopyOnWriteArrayList;
 
@@ -87,6 +88,6 @@ public class PacketInTranslator implements IMDMessageTranslator<OfHeader, List<D
                 return list;
            } 
         } 
-        return null;
+        return Collections.emptyList();
     }
 }
index 4a297141fa8a0c2c28797805b8a25372ac585582..bd44bc66793c903bd01809b4f32104bfb71a2976 100644 (file)
@@ -1,6 +1,7 @@
 package org.opendaylight.openflowplugin.openflow.md.core.translator;
 
 import java.math.BigInteger;
+import java.util.Collections;
 import java.util.List;
 import java.util.concurrent.CopyOnWriteArrayList;
 
@@ -51,7 +52,7 @@ public class PortStatusMessageToNodeConnectorUpdatedTranslator implements IMDMes
             return list;
         } else {
             // TODO - Do something smarter than returning null if translation fails... what Exception should we throw here?
-            return null;
+            return Collections.emptyList();
         }
     }
 }
index c4ff3e2b3fe4430b24f6e4788342430d2ba461d3..ff37cba3151956be7c7ac5f7f77a312d569d3f76 100644 (file)
@@ -122,8 +122,8 @@ public class TicketProcessorFactory<IN, OUT> {
                             cookie = conductor.getAuxiliaryKey();
                         }
                         List<OUT> translatorOutput = translator.translate(cookie, conductor.getSessionContext(), message);
-                        if(translatorOutput != null) {
-                            result.addAll(translator.translate(cookie, conductor.getSessionContext(), message));
+                        if(translatorOutput != null && !translatorOutput.isEmpty()) {
+                            result.addAll(translatorOutput);
                         }
                     }
                 } else {