Skip to content

Commit 50d57c1

Browse files
authored
fix: Add null check (#607)
Signed-off-by: sheche <[email protected]>
1 parent 5aa7ad8 commit 50d57c1

File tree

3 files changed

+75
-57
lines changed

3 files changed

+75
-57
lines changed

jdtls.ext/com.microsoft.jdtls.ext.core/src/com/microsoft/jdtls/ext/core/ExtUtils.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
package com.microsoft.jdtls.ext.core;
1313

14+
import java.io.File;
1415
import java.net.URI;
1516
import java.net.URISyntaxException;
1617
import java.util.Arrays;
@@ -29,6 +30,7 @@
2930
import org.eclipse.jdt.core.JavaModelException;
3031
import org.eclipse.jdt.internal.core.JarEntryDirectory;
3132
import org.eclipse.jdt.internal.core.JarEntryFile;
33+
import org.eclipse.jdt.launching.IVMInstall;
3234
import org.eclipse.jdt.launching.JavaRuntime;
3335
import org.eclipse.jdt.ls.core.internal.JavaLanguageServerPlugin;
3436

@@ -112,7 +114,15 @@ public static URI getContainerURI(IJavaProject javaProject, IClasspathContainer
112114
switch (container.getKind()) {
113115
case IClasspathContainer.K_DEFAULT_SYSTEM: // JRE Container
114116
case IClasspathContainer.K_SYSTEM:
115-
return JavaRuntime.getVMInstall(javaProject).getInstallLocation().toURI();
117+
IVMInstall vmInstall = JavaRuntime.getVMInstall(javaProject);
118+
if (vmInstall == null) {
119+
return null;
120+
}
121+
File installLocation = vmInstall.getInstallLocation();
122+
if (installLocation == null) {
123+
return null;
124+
}
125+
return installLocation.toURI();
116126
case IClasspathContainer.K_APPLICATION: // Plugin Container, Maven Container, etc
117127
return null; // TODO: find out a good way to detect these containers' uri
118128
default: // Persistent container (e.g. /src/main/java)

package-lock.json

Lines changed: 58 additions & 50 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -617,30 +617,30 @@
617617
"devDependencies": {
618618
"@types/fs-extra": "^9.0.13",
619619
"@types/glob": "^7.2.0",
620-
"@types/lodash": "^4.14.178",
620+
"@types/lodash": "^4.14.181",
621621
"@types/minimatch": "^3.0.3",
622622
"@types/mocha": "^9.1.0",
623-
"@types/node": "^14.14.0",
623+
"@types/node": "^14.18.12",
624624
"@types/semver": "^7.3.9",
625625
"@types/vscode": "1.63.0",
626626
"copy-webpack-plugin": "^9.1.0",
627627
"glob": "^7.2.0",
628628
"mocha": "^9.2.2",
629629
"ts-loader": "^9.2.8",
630630
"tslint": "^6.1.3",
631-
"typescript": "^4.6.2",
631+
"typescript": "^4.6.3",
632632
"vscode-extension-tester": "^4.2.4",
633633
"vscode-test": "^1.6.1",
634-
"webpack": "^5.70.0",
634+
"webpack": "^5.72.0",
635635
"webpack-cli": "^4.9.2"
636636
},
637637
"dependencies": {
638638
"await-lock": "^2.1.0",
639639
"fs-extra": "^10.0.1",
640640
"globby": "^11.1.0",
641641
"lodash": "^4.17.21",
642-
"minimatch": "^3.0.4",
643-
"semver": "^7.3.5",
642+
"minimatch": "^3.1.2",
643+
"semver": "^7.3.6",
644644
"vscode-extension-telemetry-wrapper": "^0.12.0",
645645
"vscode-tas-client": "^0.1.31"
646646
}

0 commit comments

Comments
 (0)