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 in CompletionResolveHandler #629

Closed
AlexTugarev opened this issue Apr 16, 2018 · 4 comments
Closed

NPE in CompletionResolveHandler #629

AlexTugarev opened this issue Apr 16, 2018 · 4 comments

Comments

@AlexTugarev
Copy link

In Theia, when suggestions are shown and you are typing, there are LS error during resolution of completion items. This following error stack is in the error messages sent back to client.

java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:63)
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.request(GenericEndpoint.java:116)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleRequest(RemoteEndpoint.java:252)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:181)
	at org.eclipse.jdt.ls.core.internal.ParentProcessWatcher.lambda$0(ParentProcessWatcher.java:83)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:183)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:92)
	at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:95)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:61)
	... 12 more
Caused by: java.util.concurrent.CompletionException: java.lang.NullPointerException
	at java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:273)
	at java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:280)
	at java.util.concurrent.CompletableFuture.uniApply(CompletableFuture.java:604)
	at java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:577)
	at java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:443)
	at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
	at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
	at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
	at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
Caused by: java.lang.NullPointerException
	at org.eclipse.jdt.ls.core.internal.handlers.CompletionResolveHandler.resolve(CompletionResolveHandler.java:72)
	at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$5(JDTLanguageServer.java:434)
	at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$21(JDTLanguageServer.java:703)
	at java.util.concurrent.CompletableFuture.uniApply(CompletableFuture.java:602)
	... 6 more
@fbricon
Copy link
Contributor

fbricon commented Apr 16, 2018

The NPE is easy to fix, but the real problem here is why isn't the data returned as a Map:

https://github.com/eclipse/eclipse.jdt.ls/blob/6c64df5646a024c0fef032298aedadeee9250d1e/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/handlers/CompletionResolveHandler.java#L69-L72

Can you paste the json payload sent to the server during completion resolution?

@AlexTugarev
Copy link
Author

In error case, there is no data attached. Which means, first call of completionItem/resolve after textDocument/completion contains the data entry, but not the subsequent ones fired when I continue typing.

textDocument/completion

screen shot 2018-04-16 at 20 09 38

item looked up from completion result

screen shot 2018-04-16 at 20 10 23

completionItem/resolve

screen shot 2018-04-16 at 20 11 16

error response

screen shot 2018-04-16 at 20 11 49

@fbricon
Copy link
Contributor

fbricon commented Apr 16, 2018

@AlexTugarev that sounds like a bug in Theia then. Again, we can fix the NPE on jdt.ls side but Theia needs to send the data that was returned during the completion.
cc @tsmaeder

@fbricon fbricon self-assigned this Apr 16, 2018
@fbricon fbricon added this to the Mid April 2018 milestone Apr 16, 2018
@AlexTugarev
Copy link
Author

Thanks for the info, @fbricon! I'll try with latest monaco version. This problem seems to be related with automatic refines of completion items. So, some items were already resolved, and when you continue typing it will re-resolve them again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants