From c5e7848220d1f14260cd35eb786dc968bfcc42eb Mon Sep 17 00:00:00 2001 From: Martin Jobst Date: Wed, 14 Aug 2024 12:20:16 +0200 Subject: [PATCH] Fix logged NPE in ViewerUpdateMonitor constructor #1500 There is a logged NPE in the constructor of ViewerUpdateMonitor when viewerInput is null. This can happen sporadically when updating tree elements during Viewer.setInput(null). This commit adds a check to avoid creating children updates when the viewer input is null. Fixes https://github.com/eclipse-platform/eclipse.platform/issues/1500 --- .../internal/ui/viewers/model/TreeModelContentProvider.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/TreeModelContentProvider.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/TreeModelContentProvider.java index 075bad86e78..04a1569aeb4 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/TreeModelContentProvider.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/TreeModelContentProvider.java @@ -1185,9 +1185,10 @@ void doUpdateElement(TreePath parentPath, int modelIndex) { Assert.isTrue( getViewer().getDisplay().getThread() == Thread.currentThread() ); Object parent = getElement(parentPath); + Object viewerInput = getViewer().getInput(); IElementContentProvider contentAdapter = ViewerAdapterService.getContentProvider(parent); - if (contentAdapter != null) { - ChildrenUpdate request = new ChildrenUpdate(this, getViewer().getInput(), parentPath, parent, modelIndex, contentAdapter); + if (viewerInput != null && contentAdapter != null) { + ChildrenUpdate request = new ChildrenUpdate(this, viewerInput, parentPath, parent, modelIndex, contentAdapter); schedule(request); } }