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

NPE when triggering signature help in class file #2102

Closed
asmodeus812 opened this issue May 28, 2022 · 9 comments · Fixed by #2124
Closed

NPE when triggering signature help in class file #2102

asmodeus812 opened this issue May 28, 2022 · 9 comments · Fixed by #2124
Labels
Milestone

Comments

@asmodeus812
Copy link

asmodeus812 commented May 28, 2022

Using nvim with jdtls i have recently started to receieve the following error. I have not observed this beforehand. No idea what it is or why its occurring
RPC[Error] code_name = InternalError, message = "Internal error." data = "java.util.concurrent.CompletionException: java.lang.NullPointerException\n\tat java.base/java.util.concurrent.CompletableFuture.encodeThrowable(Completable Future.java:314)\n\tat java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:319)\n\tat java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:645)\n\tat java. base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:479)\n\tat java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)\n\tat java.base/java.util.concurrent.ForkJoinPool$WorkQueue.t opLevelExec(ForkJoinPool.java:1020)\n\tat java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)\n\tat java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)\n\tat java.base/java.util.conc urrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)\nCaused by: java.lang.NullPointerException\n\tat org.eclipse.jdt.ls.core.internal.handlers.SignatureHelpHandler.signatureHelp(SignatureHelpHandler.java:75)\n\tat org. eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$8(JDTLanguageServer.java:591)\n\tat org.eclipse.jdt.ls.core.internal.BaseJDTLanguageServer.lambda$0(BaseJDTLanguageServer.java:75)\n\tat java.base/java.util.concurren t.CompletableFuture$UniApply.tryFire(CompletableFuture.java:642)\n\t... 6 more\n" RPC[Error] code_name = InternalError, message = "Internal error." data = "java.util.concurrent.CompletionException: java.lang.NullPointerException\n\tat java.base/java.util.concurrent.CompletableFuture.encodeThrowable(Completable Future.java:314)\n\tat java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:319)\n\tat java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:645)\n\tat java. base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:479)\n\tat java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)\n\tat java.base/java.util.concurrent.ForkJoinPool$WorkQueue.t opLevelExec(ForkJoinPool.java:1020)\n\tat java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)\n\tat java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)\n\tat java.base/java.util.conc urrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)\nCaused by: java.lang.NullPointerException\n\tat org.eclipse.jdt.ls.core.internal.handlers.SignatureHelpHandler.signatureHelp(SignatureHelpHandler.java:75)\n\tat org. eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$8(JDTLanguageServer.java:591)\n\tat org.eclipse.jdt.ls.core.internal.BaseJDTLanguageServer.lambda$0(BaseJDTLanguageServer.java:75)\n\tat java.base/java.util.concurren t.CompletableFuture$UniApply.tryFire(CompletableFuture.java:642)\n\t... 6 more\n" RPC[Error] code_name = InternalError, message = "Internal error." data = "java.util.concurrent.CompletionException: java.lang.NullPointerException\n\tat java.base/java.util.concurrent.CompletableFuture.encodeThrowable(Completable Future.java:314)\n\tat java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:319)\n\tat java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:645)\n\tat java. base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:479)\n\tat java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)\n\tat java.base/java.util.concurrent.ForkJoinPool$WorkQueue.t opLevelExec(ForkJoinPool.java:1020)\n\tat java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)\n\tat java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)\n\tat java.base/java.util.conc urrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)\nCaused by: java.lang.NullPointerException\n\tat org.eclipse.jdt.ls.core.internal.handlers.SignatureHelpHandler.signatureHelp(SignatureHelpHandler.java:75)\n\tat org. eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$8(JDTLanguageServer.java:591)\n\tat org.eclipse.jdt.ls.core.internal.BaseJDTLanguageServer.lambda$0(BaseJDTLanguageServer.java:75)\n\tat java.base/java.util.concurren t.CompletableFuture$UniApply.tryFire(CompletableFuture.java:642)\n\t... 6 more\n"

@snjeza
Copy link
Contributor

snjeza commented May 29, 2022

@asmodeus812 could you attach a sample project reproducing the error?

@asmodeus812
Copy link
Author

@snjeza I am really not capable of doing that since the project is propriatary and i am not sure what causes this issue. I will try to revert to an older jdtls and see if the issue persists. Do you have any suggestions ?

@asmodeus812
Copy link
Author

asmodeus812 commented May 30, 2022

I did try to downgrade but the same / similar issue persists. What i noticed is that it occurs when i jump to (with document go to definition) source code outside the project, for example even core java classes such as String, Map etc. Steps to reproduce

The error Below was tested and observed in both wsl and macos

  1. Cloned this random repo https://github.com/jenkins-docs/simple-java-maven-app.git
  2. Jdtls is configured to start as follows (tried with milestone builds 1.6 & 1.9 as well as snapshot build 1.12 - downloaded by default from lspinstaller)
    image
  3. Open the app.java file
  4. Go to definition of a known symbol/clas (String) for example
  5. Observe the following error (the message is printed in echo area in vim)
RPC[Error] code_name = InternalError, message = "Internal error." data = "java.util.concurrent.CompletionException: java.lang.NullPointerException\n\tat java.base/java.util.concurrent.CompletableFuture.encodeThrowable(Completable
Future.java:314)\n\tat java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:319)\n\tat java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:645)\n\tat java.
base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:479)\n\tat java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)\n\tat java.base/java.util.concurrent.ForkJoinPool$WorkQueue.t
opLevelExec(ForkJoinPool.java:1020)\n\tat java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)\n\tat java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)\n\tat java.base/java.util.conc
urrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)\nCaused by: java.lang.NullPointerException\n\tat org.eclipse.jdt.ls.core.internal.handlers.SignatureHelpHandler.signatureHelp(SignatureHelpHandler.java:76)\n\tat org.
eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$8(JDTLanguageServer.java:572)\n\tat org.eclipse.jdt.ls.core.internal.BaseJDTLanguageServer.lambda$0(BaseJDTLanguageServer.java:75)\n\tat java.base/java.util.concurren
t.CompletableFuture$UniApply.tryFire(CompletableFuture.java:642)\n\t... 6 more\n"
RPC[Error] code_name = InternalError, message = "Internal error." data = "java.util.concurrent.CompletionException: java.lang.NullPointerException\n\tat java.base/java.util.concurrent.CompletableFuture.encodeThrowable(Completable
Future.java:314)\n\tat java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:319)\n\tat java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:645)\n\tat java.
base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:479)\n\tat java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)\n\tat java.base/java.util.concurrent.ForkJoinPool$WorkQueue.t
opLevelExec(ForkJoinPool.java:1020)\n\tat java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)\n\tat java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)\n\tat java.base/java.util.conc
urrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)\nCaused by: java.lang.NullPointerException\n\tat org.eclipse.jdt.ls.core.internal.handlers.SignatureHelpHandler.signatureHelp(SignatureHelpHandler.java:76)\n\tat org.
eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$8(JDTLanguageServer.java:572)\n\tat org.eclipse.jdt.ls.core.internal.BaseJDTLanguageServer.lambda$0(BaseJDTLanguageServer.java:75)\n\tat java.base/java.util.concurren
t.CompletableFuture$UniApply.tryFire(CompletableFuture.java:642)\n\t... 6 more\n"
RPC[Error] code_name = InternalError, message = "Internal error." data = "java.util.concurrent.CompletionException: java.lang.NullPointerException\n\tat java.base/java.util.concurrent.CompletableFuture.encodeThrowable(Completable
Future.java:314)\n\tat java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:319)\n\tat java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:645)\n\tat java.
base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:479)\n\tat java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)\n\tat java.base/java.util.concurrent.ForkJoinPool$WorkQueue.t
opLevelExec(ForkJoinPool.java:1020)\n\tat java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)\n\tat java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)\n\tat java.base/java.util.conc
urrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)\nCaused by: java.lang.NullPointerException\n\tat org.eclipse.jdt.ls.core.internal.handlers.SignatureHelpHandler.signatureHelp(SignatureHelpHandler.java:76)\n\tat org.
eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$8(JDTLanguageServer.java:572)\n\tat org.eclipse.jdt.ls.core.internal.BaseJDTLanguageServer.lambda$0(BaseJDTLanguageServer.java:75)\n\tat java.base/java.util.concurren
t.CompletableFuture$UniApply.tryFire(CompletableFuture.java:642)\n\t... 6 more\n"
RPC[Error] code_name = InternalError, message = "Internal error." data = "java.util.concurrent.CompletionException: java.lang.NullPointerException\n\tat java.base/java.util.concurrent.CompletableFuture.encodeThrowable(Completable
Future.java:314)\n\tat java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:319)\n\tat java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:645)\n\tat java.
base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:479)\n\tat java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)\n\tat java.base/java.util.concurrent.ForkJoinPool$WorkQueue.t
opLevelExec(ForkJoinPool.java:1020)\n\tat java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)\n\tat java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)\n\tat java.base/java.util.conc
urrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)\nCaused by: java.lang.NullPointerException\n\tat org.eclipse.jdt.ls.core.internal.handlers.SignatureHelpHandler.signatureHelp(SignatureHelpHandler.java:76)\n\tat org.
eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$8(JDTLanguageServer.java:572)\n\tat org.eclipse.jdt.ls.core.internal.BaseJDTLanguageServer.lambda$0(BaseJDTLanguageServer.java:75)\n\tat java.base/java.util.concurren
t.CompletableFuture$UniApply.tryFire(CompletableFuture.java:642)\n\t... 6 more\n"
RPC[Error] code_name = InternalError, message = "Internal error." data = "java.util.concurrent.CompletionException: java.lang.NullPointerException\n\tat java.base/java.util.concurrent.CompletableFuture.encodeThrowable(Completable
Future.java:314)\n\tat java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:319)\n\tat java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:645)\n\tat java.
base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:479)\n\tat java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)\n\tat java.base/java.util.concurrent.ForkJoinPool$WorkQueue.t
opLevelExec(ForkJoinPool.java:1020)\n\tat java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)\n\tat java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)\n\tat java.base/java.util.conc
urrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)\nCaused by: java.lang.NullPointerException\n\tat org.eclipse.jdt.ls.core.internal.handlers.SignatureHelpHandler.signatureHelp(SignatureHelpHandler.java:76)\n\tat org.
eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$8(JDTLanguageServer.java:572)\n\tat org.eclipse.jdt.ls.core.internal.BaseJDTLanguageServer.lambda$0(BaseJDTLanguageServer.java:75)\n\tat java.base/java.util.concurren
t.CompletableFuture$UniApply.tryFire(CompletableFuture.java:642)\n\t... 6 more\n"
RPC[Error] code_name = InternalError, message = "Internal error." data = "java.util.concurrent.CompletionException: java.lang.NullPointerException\n\tat java.base/java.util.concurrent.CompletableFuture.encodeThrowable(Completable
Future.java:314)\n\tat java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:319)\n\tat java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:645)\n\tat java.
base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:479)\n\tat java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)\n\tat java.base/java.util.concurrent.ForkJoinPool$WorkQueue.t
opLevelExec(ForkJoinPool.java:1020)\n\tat java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)\n\tat java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)\n\tat java.base/java.util.conc
urrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)\nCaused by: java.lang.NullPointerException\n\tat org.eclipse.jdt.ls.core.internal.handlers.SignatureHelpHandler.signatureHelp(SignatureHelpHandler.java:76)\n\tat org.
eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$8(JDTLanguageServer.java:572)\n\tat org.eclipse.jdt.ls.core.internal.BaseJDTLanguageServer.lambda$0(BaseJDTLanguageServer.java:75)\n\tat java.base/java.util.concurren
t.CompletableFuture$UniApply.tryFire(CompletableFuture.java:642)\n\t... 6 more\n"
E21: Cannot make changes, 'modifiable' is off
RPC[Error] code_name = InternalError, message = "Internal error." data = "java.util.concurrent.CompletionException: java.lang.NullPointerException\n\tat java.base/java.util.concurrent.CompletableFuture.encodeThrowable(Completable
Future.java:314)\n\tat java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:319)\n\tat java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:645)\n\tat java.
base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:479)\n\tat java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)\n\tat java.base/java.util.concurrent.ForkJoinPool$WorkQueue.t
opLevelExec(ForkJoinPool.java:1020)\n\tat java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)\n\tat java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)\n\tat java.base/java.util.conc
urrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)\nCaused by: java.lang.NullPointerException\n\tat org.eclipse.jdt.ls.core.internal.handlers.SignatureHelpHandler.signatureHelp(SignatureHelpHandler.java:76)\n\tat org.
eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$8(JDTLanguageServer.java:572)\n\tat org.eclipse.jdt.ls.core.internal.BaseJDTLanguageServer.lambda$0(BaseJDTLanguageServer.java:75)\n\tat java.base/java.util.concurren
t.CompletableFuture$UniApply.tryFire(CompletableFuture.java:642)\n\t... 6 more\n"

Used configuration for jdtls

                    trace = {
                        server = "message",
                    },
                    signatureHelp = {
                        enabled = true
                    },
                    referenceCodeLens = {
                        enabled = true
                    },
                    format = {
                        enabled = true,
                        settings = {
                            profile = "GoogleStyle",
                            url = opts.format_file or "https://raw.githubusercontent.com/google/styleguide/gh-pages/eclipse-java-google-style.xml"
                        },
                    },
                    saveActions = {
                        organizeImports = true
                    },
                    completion = {
                        importOrder = {
                            "javax",
                            "java",
                            "com",
                            "org"
                        }
                    },
                    codeGeneration = {
                        tostring = {
                            listArrayContents = true,
                            skipNullValues = true,
                            template = "${object.className}{${member.name()}=${member.value}, ${otherMembers}}",
                        },
                        useBlocks = true,
                        hashCodeEquals = {
                            useInstanceof = true,
                            useJava7Objects = true
                        },
                        generateComments = true,
                        insertLocation = true
                    },
                    autobuild = {
                        enabled = true
                    },
                    progressReports = {
                        enabled = false
                    },
                    eclipse = {
                        downloadSources = true
                    },
                    maven = {
                        downloadSources = true,
                        updateSnapshots = true
                    }
                }

Summoning @mfussenegger for expert opinion as well since he has developed the nvim-jdtls plugin and has much better understadning of what might be going wrong here.

@snjeza
Copy link
Contributor

snjeza commented May 30, 2022

@asmodeus812 could you try to set

"java.signatureHelp.enabled": false,

@asmodeus812
Copy link
Author

asmodeus812 commented May 30, 2022

@snjeza That seems to work, there is no message being reported when i set it to false. I updated the prev post with my initial config btw. (Forgot to do that even though i intended when i was creating it)

@jdneo
Copy link
Contributor

jdneo commented Jun 1, 2022

@mfussenegger
Copy link
Contributor

Summoning @mfussenegger for expert opinion as well since he has developed the nvim-jdtls plugin and has much better understadning of what might be going wrong here.

nvim-jdtls doesn't do anything special in regards to signature help handling, that's all part of neovim-core (and working as far as I can tell). Maybe you're using some other third party plugin that implemented it incorrectly?

You could increase the log level in neovim to also log the payloads sent to the server. (See :help vim.lsp.set_log_level())

@asmodeus812
Copy link
Author

asmodeus812 commented Jun 13, 2022

Can this be classified as a bug ? Seems like it breaks jdtls with signature enabled

@jdneo
Copy link
Contributor

jdneo commented Jun 14, 2022

Ok, then it makes sense. When signature help is triggered in a class file, unit will be null after:

https://github.com/eclipse/eclipse.jdt.ls/blob/28ef246d678b91eea0cddeab72f5bc38c605399b/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/handlers/SignatureHelpHandler.java#L74

Then the NPE throws at unit.getBuffer() in
https://github.com/eclipse/eclipse.jdt.ls/blob/73b64b9eacc1f72227ff034a8e71a84351c5567a/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/handlers/SignatureHelpHandler.java#L75

Thanks for providing that information! @asmodeus812

BTW, something off the topic: Is it necessary to trigger the signature help for a GTD request? I think SH should go with completion or triggered manually by users.

@jdneo jdneo added bug and removed need info labels Jun 14, 2022
@jdneo jdneo changed the title java.util.concurrent.CompletionException NPE when triggering signature help in class file Jun 14, 2022
@jdneo jdneo added this to the End June 2022 milestone Jun 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants