kotlin-language-server icon indicating copy to clipboard operation
kotlin-language-server copied to clipboard

No proper file check, java.nio.file.AccessDeniedException

Open Jackey-Huo opened this issue 5 years ago • 1 comments

Hi~

I come from YouCompleteMe, and I use kotlin-language-server as the kotlin completer. The server is good and makes me very happy to code with my sweet editor ;).

But I found a bad feature of the server, that it does not check file accessibility. While using, I found an unexpected crash and got some error info from YCM error log. It shows below:

java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:67)
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.request(GenericEndpoint.java:120)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleRequest(RemoteEndpoint.java:261)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:190)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:192)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)
	at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:99)
	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:65)
	... 11 more
Caused by: java.io.UncheckedIOException: java.nio.file.AccessDeniedException: /home/jackey/.cache/dconf
	at java.nio.file.FileTreeIterator.fetchNextIfNeeded(FileTreeIterator.java:88)
	at java.nio.file.FileTreeIterator.hasNext(FileTreeIterator.java:104)
	at java.util.Iterator.forEachRemaining(Iterator.java:115)
	at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482)
	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
	at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:566)
	at org.javacs.kt.SourceFilesKt.findSourceFiles(SourceFiles.kt:197)
	at org.javacs.kt.SourceFilesKt.access$findSourceFiles(SourceFiles.kt:1)
	at org.javacs.kt.SourceFiles.addWorkspaceRoot(SourceFiles.kt:129)
	at org.javacs.kt.KotlinLanguageServer.initialize(KotlinLanguageServer.kt:70)
	... 16 more
Caused by: java.nio.file.AccessDeniedException: /home/jackey/.cache/dconf
	at sun.nio.fs.UnixException.translateToIOException(UnixException.java:84)
	at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
	at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
	at sun.nio.fs.UnixFileSystemProvider.newDirectoryStream(UnixFileSystemProvider.java:427)
	at java.nio.file.Files.newDirectoryStream(Files.java:457)
	at java.nio.file.FileTreeWalker.visit(FileTreeWalker.java:300)
	at java.nio.file.FileTreeWalker.next(FileTreeWalker.java:372)
	at java.nio.file.FileTreeIterator.fetchNextIfNeeded(FileTreeIterator.java:95)
	... 28 more

This crash is caused by sending the wrong workspace path to kotlin-language-server. I know all files will be readable in a common kotlin project and generally speaking, it's not the fault of the server. But for the sake of safety and easy use, may the server add a try-catch and warning part for file check?

Anyway, I think it'll be helpful for other poor guys who encounter this problem, so I put an issue here. And for a detailed solution if you use YouCompleteMe, see ycm-core/lsp-examples#5

Thanks again for your fantastic work ;)

Jackey-Huo avatar Aug 10 '19 08:08 Jackey-Huo

Hi, any news on that issue, it's very annoying

eirnym avatar Jan 22 '24 08:01 eirnym