Bug 553577 - [Async completion] avoid NPE

fComputedProposals can be changed or reset to null by other operations.
Add a check that fComputedProposals is still "bound" to current
computation before applying results.

Change-Id: If924044693dfc34013a0b9919f26c64049d6c947
Signed-off-by: Mickael Istria <mistria@redhat.com>
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/AsyncCompletionProposalPopup.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/AsyncCompletionProposalPopup.java
index ce724dd..e39bc2f 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/AsyncCompletionProposalPopup.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/AsyncCompletionProposalPopup.java
@@ -224,16 +224,18 @@
 			fComputedProposals.add(0, computingProposal);
 			setProposals(fComputedProposals, false);
 			AtomicInteger remaining= new AtomicInteger(populateFutures.size());
+			final List<ICompletionProposal> requestSpecificProposals= fComputedProposals; //fComputedProposals can be changed/reset later
 			populateFutures= populateFutures.stream().map(future -> future.thenRun(() -> {
 				computingProposal.setRemaining(remaining.decrementAndGet());
 				if (remaining.get() == 0) {
-					fComputedProposals.remove(computingProposal);
+					requestSpecificProposals.remove(computingProposal);
 				}
 				Control control= fContentAssistSubjectControlAdapter.getControl();
 				if (!control.isDisposed() && offset == fInvocationOffset) {
 					control.getDisplay().asyncExec(() -> {
-						// Don't run anything if offset has changed while runnable was scheduled (i.e. filtering might have occurred for fast CA)
-						if (offset != fInvocationOffset) {
+						// Skip if offset has changed while runnable was scheduled
+						// nor when completion "session" was modified or canceled.
+						if (offset != fInvocationOffset || fComputedProposals != requestSpecificProposals) {
 							return;
 						}
 						if (autoInsert