From 954bc581051c3f0a5ebcacc1d85492d2acd85707 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Tue, 18 Jun 2024 08:06:14 +0200 Subject: [PATCH] Fix NPE in legacyActionLabelSupport If command is null a NPE occurs even though from the code it seems this should be handled by a fallback. This replaces Optional.of with Optional.ofNullable to account for that case. --- .../e4/ui/workbench/renderers/swt/HandledContributionItem.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/HandledContributionItem.java b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/HandledContributionItem.java index 104db0fcfa2..ebd8a28e549 100644 --- a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/HandledContributionItem.java +++ b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/HandledContributionItem.java @@ -339,7 +339,7 @@ private String getToolTipText(boolean attachKeybinding) { private String legacyActionLabelSupport(String text, ParameterizedCommand command) { - return java.util.Optional.of(command).map(ParameterizedCommand::getCommand).map(Command::getHandler) + return java.util.Optional.ofNullable(command).map(ParameterizedCommand::getCommand).map(Command::getHandler) .map(IHandler::getHandlerLabel).filter(Objects::nonNull).orElse(text); }