From 0bec2cc71009b347b855af9b6be99ed37f06e48a Mon Sep 17 00:00:00 2001 From: azerr Date: Tue, 19 Jan 2021 18:04:59 +0100 Subject: [PATCH] LemMinX crashes if one extension class cannot be created Fixes #967 Signed-off-by: azerr --- .../services/extensions/XMLExtensionsRegistry.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/services/extensions/XMLExtensionsRegistry.java b/org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/services/extensions/XMLExtensionsRegistry.java index cf928913e..ad7a19676 100644 --- a/org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/services/extensions/XMLExtensionsRegistry.java +++ b/org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/services/extensions/XMLExtensionsRegistry.java @@ -15,8 +15,10 @@ import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.ServiceConfigurationError; import java.util.ServiceLoader; import java.util.logging.Level; import java.util.logging.Logger; @@ -223,10 +225,14 @@ private synchronized void initialize() { if (commandService != null) { commandService.beginCommandsRegistration(); } - ServiceLoader extensions = ServiceLoader.load(IXMLExtension.class); - extensions.forEach(extension -> { - registerExtension(extension); - }); + Iterator extensions = ServiceLoader.load(IXMLExtension.class).iterator(); + while (extensions.hasNext()) { + try { + registerExtension(extensions.next()); + } catch (ServiceConfigurationError e) { + LOGGER.log(Level.SEVERE, "Error while instantiating extension", e); + } + } initialized = true; if (commandService != null) { commandService.endCommandsRegistration();