From c90aa0d9b7ee128768ef0072f489dfac0804fc2d Mon Sep 17 00:00:00 2001 From: Lars Vogel Date: Mon, 28 Sep 2026 08:24:11 +0200 Subject: [PATCH] Fix NPE in AntConsoleColorProvider after console disconnect MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A color preference change schedules an async stream update, which can run after the console was disconnected and getConsole() returns null. Skip the update in that case. Assisted-by: multiple AI agents and layers of automated tooling 🤖 --- .../ant/internal/ui/console/AntConsoleColorProvider.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/console/AntConsoleColorProvider.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/console/AntConsoleColorProvider.java index 407dbce6461..bee60d5c59c 100644 --- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/console/AntConsoleColorProvider.java +++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/console/AntConsoleColorProvider.java @@ -73,7 +73,12 @@ public void propertyChange(PropertyChangeEvent event) { final String streamId = getStreamId(event.getProperty()); if (streamId != null) { AntUIPlugin.getStandardDisplay().asyncExec(() -> { - IOConsoleOutputStream stream = getConsole().getStream(streamId); + IConsole console = getConsole(); + if (console == null) { + // disconnected before the runnable ran + return; + } + IOConsoleOutputStream stream = console.getStream(streamId); if (stream != null) { stream.setColor(getColor(streamId)); }