lsp4intellij icon indicating copy to clipboard operation
lsp4intellij copied to clipboard

Error when changing classpath by re-importing a project while language server is not running

Open gayanper opened this issue 4 years ago • 5 comments

java.util.concurrent.ExecutionException: org.eclipse.lsp4j.jsonrpc.JsonRpcException: java.io.IOException: The pipe is being closed
	at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:395)
	at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1999)
	at org.spring.tools.boot.java.ls.java.ClasspathListener.sendClasspathCommand(ClasspathListener.java:167)
	at org.spring.tools.boot.java.ls.java.ClasspathListener.access$100(ClasspathListener.java:40)
	at org.spring.tools.boot.java.ls.java.ClasspathListener$LSModuleRootListener.lambda$rootsChanged$1(ClasspathListener.java:189)
	at com.intellij.openapi.application.impl.ApplicationImpl$2.call(ApplicationImpl.java:322)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: org.eclipse.lsp4j.jsonrpc.JsonRpcException: java.io.IOException: The pipe is being closed
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageConsumer.consume(StreamMessageConsumer.java:72)
	at org.wso2.lsp4intellij.client.languageserver.wrapper.MessageHandler.lambda$apply$0(MessageHandler.java:45)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.request(RemoteEndpoint.java:161)
	at org.eclipse.lsp4j.jsonrpc.services.EndpointProxy.invoke(EndpointProxy.java:91)
	at com.sun.proxy.$Proxy113.executeCommand(Unknown Source)
	at org.wso2.lsp4intellij.client.languageserver.requestmanager.DefaultRequestManager.executeCommand(DefaultRequestManager.java:218)
	at org.spring.tools.boot.java.ls.java.ClasspathListener.sendClasspathCommand(ClasspathListener.java:164)
	... 7 more
Caused by: java.io.IOException: The pipe is being closed
	at java.base/java.io.FileOutputStream.writeBytes(Native Method)
	at java.base/java.io.FileOutputStream.write(FileOutputStream.java:354)
	at java.base/java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:81)
	at java.base/java.io.BufferedOutputStream.write(BufferedOutputStream.java:122)
	at java.base/java.io.FilterOutputStream.write(FilterOutputStream.java:108)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageConsumer.consume(StreamMessageConsumer.java:68)
	... 13 more

gayanper avatar Nov 07 '19 06:11 gayanper

@NipunaRanasinghe seems like the concurrent issue to me. I guess that the server is shutting down between the execution of line 44-45 in org.wso2.lsp4intellij.client.languageserver.wrapper.MessageHandler. May be we need a way to synchronize this. double check will of course help here but not 100%. WDYT ?

gayanper avatar Nov 09 '19 11:11 gayanper

@gayanper I'm not sure about the root cause but I think maybe we can gracefully handle this by wrapping using a try catch block (at least for now) since org.eclipse.lsp4j.jsonrpc.json.SteamMwssageConsumer:72 is throwing a JsonRpcException for any IOException. WDYT?

By the way can we consider this exception as the stop/terminate condition for the message consumer?

NipunaRanasinghe avatar Nov 13 '19 05:11 NipunaRanasinghe

@NipunaRanasinghe does lsp4j throw JsonRpcException when it can't deserialize message from LS? BSL LS use stdin/stdout for language client - language server communication AND also writes error messages to stdout. Will it be considered as termination condition in your suggestion?

nixel2007 avatar Nov 13 '19 06:11 nixel2007

@nixel2007 I'm don't have a deeper knowledge on the lsp4j implementation but it seems they use JsonRpcException only when accessing the JSON-RPC communication channel fails. So this wont affect the BSL implementation I guess :)

NipunaRanasinghe avatar Nov 13 '19 07:11 NipunaRanasinghe

Okay, thank you!

nixel2007 avatar Nov 13 '19 07:11 nixel2007