ONOS-5309 Clearing installables from intent data object on successful uninstallation

Change-Id: Ic77af12f98bc1519efb2e2703223e340aa5b20e4
(cherry picked from commit 24389970b336c3bb2fb883f2aaa87f7b457bde4a)
diff --git a/core/api/src/main/java/org/onosproject/net/intent/IntentData.java b/core/api/src/main/java/org/onosproject/net/intent/IntentData.java
index 84acfc3..feada17 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/IntentData.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/IntentData.java
@@ -114,7 +114,8 @@
     public IntentData(IntentData original, List<Intent> installables) {
         this(original);
 
-        this.installables = ImmutableList.copyOf(checkNotNull(installables));
+        this.installables = checkNotNull(installables).isEmpty() ?
+                Collections.emptyList() : ImmutableList.copyOf(installables);
     }
 
     // kryo constructor
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/IntentInstaller.java b/core/net/src/main/java/org/onosproject/net/intent/impl/IntentInstaller.java
index 332ca73..1e569c4 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/IntentInstaller.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/IntentInstaller.java
@@ -36,6 +36,7 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Optional;
@@ -112,7 +113,8 @@
                         uninstallData.setState(WITHDRAWN);
                         break;
                 }
-                store.write(uninstallData);
+                // Intent has been withdrawn; we can clear the installables
+                store.write(new IntentData(uninstallData, Collections.emptyList()));
             }
         };