[CORD-197] Properly handles a flow with empty instruction

Change-Id: Ia465fdc8df1dca7a46249cd4cd8d41faf8461c3a
diff --git a/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java b/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java
index bf650c0..26ab1bd 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java
@@ -234,6 +234,7 @@
 
             switch (instruction.type()) {
                 case DROP:
+                case NOACTION:
                 case OUTPUT:
                 case GROUP:
                 case L0MODIFICATION:
@@ -259,9 +260,23 @@
             return this;
         }
 
+        /**
+         * Add a NOACTION when DROP instruction is explicitly specified.
+         *
+         * @return the traffic treatment builder
+         */
         @Override
         public Builder drop() {
-            return add(Instructions.createDrop());
+            return add(Instructions.createNoAction());
+        }
+
+        /**
+         * Add a NOACTION when no instruction is specified.
+         *
+         * @return the traffic treatment builder
+         */
+        private Builder noAction() {
+            return add(Instructions.createNoAction());
         }
 
         @Override
@@ -459,14 +474,10 @@
 
         @Override
         public TrafficTreatment build() {
-            //Don't add DROP instruction by default when instruction
-            //set is empty. This will be handled in DefaultSingleTablePipeline
-            //driver.
-
-            //if (deferred.size() == 0 && immediate.size() == 0
-            //        && table == null && !clear) {
-            //    drop();
-            //}
+            if (deferred.size() == 0 && immediate.size() == 0
+                    && table == null && !clear) {
+                noAction();
+            }
             return new DefaultTrafficTreatment(deferred, immediate, table, clear, meta, meter);
         }