LSP4J_Tutorial icon indicating copy to clipboard operation
LSP4J_Tutorial copied to clipboard

\r\n causes NumberFormatException from StreamMessageProducer?

Open Huxpro opened this issue 6 years ago • 0 comments

Start the server!
Content-Length: 44\r\n
\r\n
{
  "jsonrpc": "2.0",
  "method": "exit"
}Jun 09, 2019 2:14:22 PM org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer fireError
SEVERE: For input string: "44\r\n"
java.lang.NumberFormatException: For input string: "44\r\n"
	at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
	at java.lang.Integer.parseInt(Integer.java:580)
	at java.lang.Integer.parseInt(Integer.java:615)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.parseHeader(StreamMessageProducer.java:119)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:86)
	at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:84)
	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)

I am trying to test the server from CLI. It seems like \r\n will be mis-interpreted as the number part of Content-Length of header? And without \r\n the server seems do nothing.

FYI I had

public void exit() {
  System.out.println("Exit!");
}

But didn't see Exit! outputted.

Thanks ;)

Huxpro avatar Jun 09 '19 21:06 Huxpro