Skip to content

Commit 266c22d

Browse files
committed
fix: prevent an exception during LanguageServerPlugin#stop
org.osgi.framework.BundleException: Exception in org.eclipse.lsp4e.LanguageServerPlugin.stop() of bundle org.eclipse.lsp4e. at org.eclipse.osgi.internal.framework.BundleContextImpl.stop(BundleContextImpl.java:928) at org.eclipse.osgi.internal.framework.EquinoxBundle.stopWorker0(EquinoxBundle.java:1096) at org.eclipse.osgi.internal.framework.EquinoxBundle$EquinoxModule.stopWorker(EquinoxBundle.java:399) at org.eclipse.osgi.container.Module.doStop(Module.java:699) at org.eclipse.osgi.container.Module.stop(Module.java:557) at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.decStartLevel(ModuleContainer.java:2153) at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:2022) at org.eclipse.osgi.container.SystemModule.stopWorker(SystemModule.java:281) at org.eclipse.osgi.internal.framework.EquinoxBundle$SystemBundle$EquinoxSystemModule.stopWorker(EquinoxBundle.java:225) at org.eclipse.osgi.container.Module.doStop(Module.java:699) at org.eclipse.osgi.container.Module.stop(Module.java:557) at org.eclipse.osgi.container.SystemModule.stop(SystemModule.java:212) at org.eclipse.osgi.internal.framework.EquinoxBundle$SystemBundle$EquinoxSystemModule$1.run(EquinoxBundle.java:244) at java.base/java.lang.Thread.run(Thread.java:1583) Caused by: java.lang.ExceptionInInitializerError at org.eclipse.lsp4e.LanguageServerPlugin.stop(LanguageServerPlugin.java:72) at org.eclipse.osgi.internal.framework.BundleContextImpl$3.run(BundleContextImpl.java:908) at org.eclipse.osgi.internal.framework.BundleContextImpl$3.run(BundleContextImpl.java:1) at java.base/java.security.AccessController.doPrivileged(AccessController.java:571) at org.eclipse.osgi.internal.framework.BundleContextImpl.stop(BundleContextImpl.java:900) ... 13 more Caused by: java.lang.NullPointerException: Cannot invoke "java.util.Set.add(Object)" because "this.resourcesWithZoomSupport" is null at org.eclipse.swt.graphics.Device.registerResourceWithZoomSupport(Device.java:966) at org.eclipse.swt.graphics.Image.<init>(Image.java:247) at org.eclipse.lsp4e.ui.LSPImages.<clinit>(LSPImages.java:69) ... 18 more Root exception: java.lang.ExceptionInInitializerError at org.eclipse.lsp4e.LanguageServerPlugin.stop(LanguageServerPlugin.java:72) at org.eclipse.osgi.internal.framework.BundleContextImpl$3.run(BundleContextImpl.java:908) at org.eclipse.osgi.internal.framework.BundleContextImpl$3.run(BundleContextImpl.java:1) at java.base/java.security.AccessController.doPrivileged(AccessController.java:571) at org.eclipse.osgi.internal.framework.BundleContextImpl.stop(BundleContextImpl.java:900) at org.eclipse.osgi.internal.framework.EquinoxBundle.stopWorker0(EquinoxBundle.java:1096) at org.eclipse.osgi.internal.framework.EquinoxBundle$EquinoxModule.stopWorker(EquinoxBundle.java:399) at org.eclipse.osgi.container.Module.doStop(Module.java:699) at org.eclipse.osgi.container.Module.stop(Module.java:557) at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.decStartLevel(ModuleContainer.java:2153) at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:2022) at org.eclipse.osgi.container.SystemModule.stopWorker(SystemModule.java:281) at org.eclipse.osgi.internal.framework.EquinoxBundle$SystemBundle$EquinoxSystemModule.stopWorker(EquinoxBundle.java:225) at org.eclipse.osgi.container.Module.doStop(Module.java:699) at org.eclipse.osgi.container.Module.stop(Module.java:557) at org.eclipse.osgi.container.SystemModule.stop(SystemModule.java:212) at org.eclipse.osgi.internal.framework.EquinoxBundle$SystemBundle$EquinoxSystemModule$1.run(EquinoxBundle.java:244) at java.base/java.lang.Thread.run(Thread.java:1583) Caused by: java.lang.NullPointerException: Cannot invoke "java.util.Set.add(Object)" because "this.resourcesWithZoomSupport" is null at org.eclipse.swt.graphics.Device.registerResourceWithZoomSupport(Device.java:966) at org.eclipse.swt.graphics.Image.<init>(Image.java:247) at org.eclipse.lsp4e.ui.LSPImages.<clinit>(LSPImages.java:69) ... 18 more
1 parent ebb9170 commit 266c22d

3 files changed

Lines changed: 14 additions & 7 deletions

File tree

org.eclipse.lsp4e/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
22
Bundle-ManifestVersion: 2
33
Bundle-Name: Language Server Protocol client for Eclipse IDE (Incubation)
44
Bundle-SymbolicName: org.eclipse.lsp4e;singleton:=true
5-
Bundle-Version: 0.19.10.qualifier
5+
Bundle-Version: 0.19.11.qualifier
66
Bundle-RequiredExecutionEnvironment: JavaSE-21
77
Require-Bundle: org.eclipse.core.runtime;bundle-version="3.12.0",
88
org.eclipse.equinox.common;bundle-version="3.8.0",

org.eclipse.lsp4e/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</parent>
1111
<artifactId>org.eclipse.lsp4e</artifactId>
1212
<packaging>eclipse-plugin</packaging>
13-
<version>0.19.10-SNAPSHOT</version>
13+
<version>0.19.11-SNAPSHOT</version>
1414

1515
<build>
1616
<plugins>

org.eclipse.lsp4e/src/org/eclipse/lsp4e/ui/LSPImages.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import java.util.HashMap;
1818
import java.util.Map;
1919
import java.util.Objects;
20+
import java.util.Optional;
2021
import java.util.stream.Stream;
2122

2223
import org.eclipse.core.runtime.FileLocator;
@@ -66,7 +67,7 @@ private LSPImages() {
6667
private static final String ACTION = ICONS_PATH + "elcl16/"; // basic colors - size 16x16 //$NON-NLS-1$
6768
private static final String OVERLAY = ICONS_PATH + "ovr16/"; // basic colors - size 7x8 and 14x16 //$NON-NLS-1$
6869

69-
private static final Image EMPTY_IMAGE = new Image(UI.getDisplay(), 16, 16);
70+
private static @Nullable Image emptyImage;
7071

7172
public static final String IMG_MODULE = "IMG_MODULE"; //$NON-NLS-1$
7273
public static final String IMG_NAMESPACE = "IMG_NAMESPACE"; //$NON-NLS-1$
@@ -240,12 +241,16 @@ private record ImageWithOverlaysKey(String baseImageKey,
240241
@Nullable ImageDescriptor underlayDescriptor) {}
241242

242243
/**
243-
* Returns an empty fallback image f(16x16 pixels).
244+
* Returns an empty fallback image (16x16 pixels).
244245
*
245246
* @return an empty 16x16 icon
246247
*/
247248
public static Image getEmptyImage() {
248-
return EMPTY_IMAGE;
249+
Image img = emptyImage;
250+
if (img == null) {
251+
img = emptyImage = new Image(UI.getDisplay(), 16, 16);
252+
}
253+
return img;
249254
}
250255

251256
/**
@@ -543,12 +548,14 @@ private static String imageOverlayKeyFromSymbolTag(SymbolTag symbolTag) {
543548
}
544549

545550
public static final void dispose() {
546-
Stream.concat(
551+
Stream.concat(Stream.concat(
547552
colorToImageCache.values().stream(),
548-
overlayImagesCache.values().stream())
553+
overlayImagesCache.values().stream()
554+
), Optional.ofNullable(emptyImage).stream())
549555
.filter(Objects::nonNull)
550556
.forEach(Image::dispose);
551557
overlayImagesCache.clear();
552558
colorToImageCache.clear();
559+
emptyImage = null;
553560
}
554561
}

0 commit comments

Comments
 (0)