Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.NullPointerException: Cannot invoke "java.util.concurrent.CompletableFuture.thenRun(java.lang.Runnable)" because "this.initializeFuture" is null #748

Closed
gastaldi opened this issue Mar 1, 2023 · 16 comments · Fixed by #765
Labels
bug Something isn't working lsp4ij LSP client for IJ severity/major
Milestone

Comments

@gastaldi
Copy link
Contributor

gastaldi commented Mar 1, 2023

Using 1.16.0.329 version. Getting the following error while working with the Quarkus project in https://github.com/quarkusio/registry.quarkus.io

Internal error: java.lang.NullPointerException: Cannot invoke "java.util.concurrent.CompletableFuture.thenRun(java.lang.Runnable)" because "this.initializeFuture" is null

java.util.concurrent.CompletionException: java.lang.NullPointerException: Cannot invoke "java.util.concurrent.CompletableFuture.thenRun(java.lang.Runnable)" because "this.initializeFuture" is null
	at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:315)
	at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:320)
	at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1807)
	at java.base/java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1796)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)
Caused by: java.lang.NullPointerException: Cannot invoke "java.util.concurrent.CompletableFuture.thenRun(java.lang.Runnable)" because "this.initializeFuture" is null
	at com.redhat.devtools.intellij.quarkus.lsp4ij.LanguageServerWrapper.registerCapability(LanguageServerWrapper.java:727)
	at com.redhat.devtools.intellij.quarkus.lsp4ij.LanguageClientImpl.lambda$registerCapability$2(LanguageClientImpl.java:85)
	at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804)
	... 6 more
gastaldi added a commit to gastaldi/intellij-quarkus that referenced this issue Mar 2, 2023
gastaldi added a commit to gastaldi/intellij-quarkus that referenced this issue Mar 2, 2023
gastaldi added a commit to gastaldi/intellij-quarkus that referenced this issue Mar 2, 2023
@adietish adietish added bug Something isn't working severity/major labels Mar 30, 2023
@adietish
Copy link
Contributor

I can confirm this, it happened to me.

angelozerr added a commit to angelozerr/intellij-quarkus that referenced this issue Mar 31, 2023
"java.util.concurrent.CompletableFuture.thenRun(java.lang.Runnable)"
because "this.initializeFuture" is null

Fixes redhat-developer#748

Signed-off-by: azerr <[email protected]>
adietish pushed a commit that referenced this issue Mar 31, 2023
"java.util.concurrent.CompletableFuture.thenRun(java.lang.Runnable)"
because "this.initializeFuture" is null

Fixes #748

Signed-off-by: azerr <[email protected]>
@adietish
Copy link
Contributor

We merged a fix which seems to resolve the issue. The issue being intermittent (it's a race condition) makes it hard to be fully sure though. Feel free to reopen if it still happens to you.

@gastaldi
Copy link
Contributor Author

This is still appearing in 1.17.0.338. Any chance to cut a release soon with the fix? This is really annoying

@angelozerr
Copy link
Contributor

@adietish 1.17.0.338 contains this fix?

@jeffmaury
Copy link
Member

@angelozerr
Copy link
Contributor

No see https://github.com/redhat-developer/intellij-quarkus/commits/1.17.0

Thanks @jeffmaury

Anyway I plan to refactor this initialization to align it with LSP4E which has improved the start of the language server.

@angelozerr angelozerr modified the milestone: 1.18.0 Apr 19, 2023
@adietish
Copy link
Contributor

adietish commented Apr 26, 2023

The fix #765 for this was included in 1.17.1. See 02ba90c
It seems to still happen to @gastaldi with 1.17.1:

Internal error: java.lang.NullPointerException: Cannot invoke "java.util.concurrent.CompletableFuture.thenRun(java.lang.Runnable)" because "this.initializeFuture" is null

java.util.concurrent.CompletionException: java.lang.NullPointerException: Cannot invoke "java.util.concurrent.CompletableFuture.thenRun(java.lang.Runnable)" because "this.initializeFuture" is null
	at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:315)
	at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:320)
	at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1807)
	at java.base/java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1796)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)
Caused by: java.lang.NullPointerException: Cannot invoke "java.util.concurrent.CompletableFuture.thenRun(java.lang.Runnable)" because "this.initializeFuture" is null
	at com.redhat.devtools.intellij.quarkus.lsp4ij.LanguageServerWrapper.registerCapability(LanguageServerWrapper.java:731)
	at com.redhat.devtools.intellij.quarkus.lsp4ij.LanguageClientImpl.lambda$registerCapability$2(LanguageClientImpl.java:85)
	at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804)
	... 6 more

Reopening.

@adietish adietish reopened this Apr 26, 2023
@angelozerr
Copy link
Contributor

I would like to improve the start of language server, after I will finish #819

@angelozerr
Copy link
Contributor

I have never reproduced this problem, it wil hard to test my future fix.

@gastaldi @jankod do you have constantly this problem?

@jankod
Copy link

jankod commented Apr 27, 2023

I have never reproduced this problem, it wil hard to test my future fix.

@gastaldi @jankod do you have constantly this problem?

Not really, but I didn't use that plugin much.

@gastaldi
Copy link
Contributor Author

gastaldi commented May 8, 2023

This error appeared again in 1.18.0.373:

Internal error: java.lang.NullPointerException: Cannot invoke "java.util.concurrent.CompletableFuture.thenRun(java.lang.Runnable)" because "this.initializeFuture" is null

java.util.concurrent.CompletionException: java.lang.NullPointerException: Cannot invoke "java.util.concurrent.CompletableFuture.thenRun(java.lang.Runnable)" because "this.initializeFuture" is null
	at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:315)
	at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:320)
	at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1807)
	at java.base/java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1796)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)
Caused by: java.lang.NullPointerException: Cannot invoke "java.util.concurrent.CompletableFuture.thenRun(java.lang.Runnable)" because "this.initializeFuture" is null
	at com.redhat.devtools.intellij.quarkus.lsp4ij.LanguageServerWrapper.registerCapability(LanguageServerWrapper.java:731)
	at com.redhat.devtools.intellij.quarkus.lsp4ij.LanguageClientImpl.lambda$registerCapability$2(LanguageClientImpl.java:86)
	at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804)
	... 6 more

@gastaldi
Copy link
Contributor Author

gastaldi commented May 8, 2023

Another NPE, maybe unrelated:

Internal error: java.lang.NullPointerException: Cannot invoke "String.length()" because "suffix" is null

java.util.concurrent.CompletionException: java.lang.NullPointerException: Cannot invoke "String.length()" because "suffix" is null
	at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:332)
	at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:347)
	at java.base/java.util.concurrent.CompletableFuture$UniAccept.tryFire(CompletableFuture.java:708)
	at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510)
	at java.base/java.util.concurrent.CompletableFuture.completeExceptionally(CompletableFuture.java:2162)
	at com.redhat.devtools.intellij.quarkus.lsp4ij.IndexAwareLanguageClient.runTask(IndexAwareLanguageClient.java:101)
	at com.redhat.devtools.intellij.quarkus.lsp4ij.IndexAwareLanguageClient$1.run(IndexAwareLanguageClient.java:76)
	at com.intellij.openapi.progress.impl.CoreProgressManager.startTask(CoreProgressManager.java:429)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.startTask(ProgressManagerImpl.java:114)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcessWithProgressInCurrentThread$11(CoreProgressManager.java:557)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:186)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeProcessUnderProgress$13(CoreProgressManager.java:604)
	at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:679)
	at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:635)
	at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:603)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:60)
	at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:173)
	at com.intellij.openapi.progress.impl.CoreProgressManager.runProcessWithProgressInCurrentThread(CoreProgressManager.java:557)
	at com.intellij.openapi.progress.impl.CoreProgressManager.run(CoreProgressManager.java:363)
	at com.redhat.devtools.intellij.quarkus.lsp4ij.IndexAwareLanguageClient.lambda$runAsBackground$0(IndexAwareLanguageClient.java:73)
	at com.redhat.devtools.intellij.quarkus.lsp4ij.IndexAwareLanguageClient.lambda$runAsBackground$1(IndexAwareLanguageClient.java:87)
	at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804)
	at java.base/java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1796)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)
Caused by: java.lang.NullPointerException: Cannot invoke "String.length()" because "suffix" is null
	at java.base/java.lang.String.endsWith(String.java:2313)
	at com.redhat.devtools.intellij.qute.psi.utils.AnnotationUtils.isMatchAnnotation(AnnotationUtils.java:85)
	at com.redhat.devtools.intellij.qute.psi.internal.java.AbstractQuteTemplateLinkCollector.visitClass(AbstractQuteTemplateLinkCollector.java:139)
	at com.intellij.psi.impl.source.PsiClassImpl.accept(PsiClassImpl.java:464)
	at com.intellij.psi.impl.source.tree.SharedImplUtil.acceptChildren(SharedImplUtil.java:185)
	at com.intellij.psi.impl.source.PsiFileImpl.acceptChildren(PsiFileImpl.java:765)
	at com.intellij.psi.JavaRecursiveElementVisitor.visitElement(JavaRecursiveElementVisitor.java:44)
	at com.intellij.psi.PsiElementVisitor.visitFile(PsiElementVisitor.java:51)
	at com.intellij.psi.JavaElementVisitor.visitJavaFile(JavaElementVisitor.java:212)
	at com.intellij.psi.impl.source.PsiJavaFileBaseImpl.accept(PsiJavaFileBaseImpl.java:478)
	at com.redhat.devtools.intellij.qute.psi.internal.java.QuarkusIntegrationForQute.diagnostics(QuarkusIntegrationForQute.java:51)
	at com.redhat.devtools.intellij.qute.psi.QuteSupportForJava.diagnostics(QuteSupportForJava.java:86)
	at com.redhat.devtools.intellij.qute.lsp.QuteLanguageClient.lambda$getJavaDiagnostics$12(QuteLanguageClient.java:134)
	at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:891)
	at com.intellij.openapi.application.ReadAction.compute(ReadAction.java:69)
	at com.redhat.devtools.intellij.qute.lsp.QuteLanguageClient.lambda$getJavaDiagnostics$13(QuteLanguageClient.java:134)
	at com.redhat.devtools.intellij.quarkus.lsp4ij.IndexAwareLanguageClient.runTask(IndexAwareLanguageClient.java:97)
	... 22 more

@angelozerr
Copy link
Contributor

My plan is to provide a console to see the lsp request responses which will help us to understand what it happens.

After that I will work on #835 to improve start/stop of language server

@turkeylurkey
Copy link
Contributor

There is a line in LanguageServerWrapper.logMessage() that can echo the messages to the current console if you just want to debug it. The issue seems to be that some local threads are shutting down LS's on project switch and other threads are starting LS's for the new project and they need to be synchronised.

@angelozerr
Copy link
Contributor

Indeed there is this piece of code which seems causing some problem but I think that there are another piece of code which causes some other problem. My plan is to align LSP4IJ from LSP4E which improves the start/stop of language server and play with the start/stop of language server by debugging a language server (like microProfile) to emulate long time in itinitalize, etc.

@angelozerr
Copy link
Contributor

Performance and freeze problem should be fixed with #849

Please repoen if you find some again troubles

@angelozerr angelozerr added this to the 1.19.0 milestone May 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment