Fix corrupted cache when clear interrupts cache population request

Change-Id: Ifebd1362ebfdaafcf0d13140c927680400580aed
Reviewed-on: https://git.eclipse.org/r/9052
Tested-by: Hudson CI
Reviewed-by: Bernd Hufmann <bhufmann@gmail.com>
IP-Clean: Bernd Hufmann <bhufmann@gmail.com>
Tested-by: Bernd Hufmann <bhufmann@gmail.com>
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsCache.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsCache.java
index 69098bc..60e9076 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsCache.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsCache.java
@@ -100,6 +100,9 @@
      * Clear the current contents of this cache.
      */
     public synchronized void clear() {
+        if (job != null && job.getState() != Job.NONE) {
+            job.cancel();
+        }
         Arrays.fill(fCache, null);
         fCacheStartIndex = 0;
         fCacheEndIndex = 0;