From da09460352afdea10658683cf429b9e3674c01ad Mon Sep 17 00:00:00 2001 From: Andrew Eidsness Date: Thu, 19 Jun 2014 14:13:31 -0400 Subject: [PATCH] Bug 437525: NPE in QMakeProjectInfoManager This fixes the NPE but not the underlying reason for the Qt plugin to be activated. I think that might be happening because of the Codan checker -- from what I recall, that extension point doesn't have a way to prevent plugin activation. The NPE is fixed by checking CACHE for null before using it. The #stop method unregisters and sets CACHE to null. However, unregistering doesn't prevent notifications that are already in flight. I suspect that notification arrives, and then CACHE is null. My test workspace would throw the NPE on every exit, with this change it never does. Change-Id: I01360a4c19c85fba53269d265948daf6d083c8d1 Signed-off-by: Andrew Eidsness Reviewed-on: https://git.eclipse.org/r/28751 Tested-by: Hudson CI Reviewed-by: Doug Schaefer --- .../qt/core/index/QMakeProjectInfoManager.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/index/QMakeProjectInfoManager.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/index/QMakeProjectInfoManager.java index 46e51b42e14..091f54abcb8 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/index/QMakeProjectInfoManager.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/index/QMakeProjectInfoManager.java @@ -79,6 +79,11 @@ public class QMakeProjectInfoManager { private static QMakeProjectInfo getQMakeProjectInfoFor(IProject project, boolean create) { QMakeProjectInfo info; synchronized (CACHE_SYNC) { + // If the cache is null then this must be a late notification after shutdown. We + // can't do anything so don't try. + if (CACHE == null) + return null; + info = CACHE.get(project); if (info != null) { return info; @@ -98,6 +103,11 @@ public class QMakeProjectInfoManager { private static void removeProjectFromCache(IResource project) { QMakeProjectInfo info; synchronized (CACHE_SYNC) { + // If the cache is null then this must be a late notification after shutdown. We + // can't do anything so don't try. + if (CACHE == null) + return; + info = CACHE.remove(project); } if (info != null) { @@ -213,6 +223,11 @@ public class QMakeProjectInfoManager { List infos; synchronized (CACHE_SYNC) { + // If the cache is null then this must be a late notification after shutdown. We + // can't do anything so don't try. + if (CACHE == null) + return; + infos = new ArrayList(CACHE.values()); } for (QMakeProjectInfo info : infos) {