OpenLiberty / liberty-tools-vscode

Visual Studio Code extension for Liberty Tools
https://marketplace.visualstudio.com/items?itemName=Open-Liberty.liberty-dev-vscode-ext
Eclipse Public License 2.0
17 stars 34 forks source link

Language support for Java throwing exception while triggering Jakarta or MicroProfile snippets in an empty file for both Java 17 and Java 21 #345

Open gilbysunil14 opened 1 month ago

gilbysunil14 commented 1 month ago

Language support for java is throwing the following exception while triggering Jakarta or MicroProfile snippets in an empty java file. This is happening for java versions 17 and 21.

The exception can be seen by following the below steps:

  1. Take the output tab in the VS code and select Language Support for Java
  2. Create an empty java file.
  3. Trigger Jakarta snippet like rest_class or MicroProfile snippet like mpreadiness.

https://github.com/user-attachments/assets/e0578abf-3a08-4922-a8e3-fcf4bbce415a

The exception in the Language Support for Java is as follows:

Oct 15, 2024 1:39:52 PM org.eclipse.lsp4mp.jdt.internal.core.java.completion.JavaCompletionDefinition collectCompletionItems
SEVERE: Error while calling collectCompletionItems
java.lang.NullPointerException: Cannot invoke "org.eclipse.jdt.core.IJavaElement.getElementType()" because "element" is null
    at org.eclipse.lsp4mp.jdt.internal.faulttolerance.java.MicroProfileFaultToleranceCompletionParticipant.getFallbackAnnotation(MicroProfileFaultToleranceCompletionParticipant.java:102)
    at org.eclipse.lsp4mp.jdt.internal.faulttolerance.java.MicroProfileFaultToleranceCompletionParticipant.collectCompletionItems(MicroProfileFaultToleranceCompletionParticipant.java:72)
    at org.eclipse.lsp4mp.jdt.internal.core.java.completion.JavaCompletionDefinition.collectCompletionItems(JavaCompletionDefinition.java:59)
    at org.eclipse.lsp4mp.jdt.core.PropertiesManagerForJava.lambda$5(PropertiesManagerForJava.java:239)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
    at org.eclipse.lsp4mp.jdt.core.PropertiesManagerForJava.completion(PropertiesManagerForJava.java:237)
    at org.eclipse.lsp4mp.jdt.internal.core.ls.MicroProfileDelegateCommandHandlerForJava.getCompletionForJava(MicroProfileDelegateCommandHandlerForJava.java:293)
    at org.eclipse.lsp4mp.jdt.internal.core.ls.MicroProfileDelegateCommandHandlerForJava.executeCommand(MicroProfileDelegateCommandHandlerForJava.java:92)
    at org.eclipse.jdt.ls.core.internal.handlers.WorkspaceExecuteCommandHandler$1.run(WorkspaceExecuteCommandHandler.java:230)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
    at org.eclipse.jdt.ls.core.internal.handlers.WorkspaceExecuteCommandHandler.executeCommand(WorkspaceExecuteCommandHandler.java:220)
    at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$4(JDTLanguageServer.java:606)
    at org.eclipse.jdt.ls.core.internal.BaseJDTLanguageServer.lambda$0(BaseJDTLanguageServer.java:87)
    at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:646)
    at java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:483)
    at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387)
    at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1312)
    at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1843)
    at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1808)
    at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:188)
gilbysunil14 commented 1 month ago

Upon analysis found that the issue is from lsp4mp.