eclipse-lsp4j / lsp4j

A Java implementation of the language server protocol intended to be consumed by tools and language servers implemented in Java.
https://eclipse.org/lsp4j
Other
581 stars 141 forks source link

The problem of org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer #811

Closed linqingying123 closed 4 months ago

linqingying123 commented 4 months ago

About the fireError method of the org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer class frequently reports an error Missing header Content-Length in input " " Java.lang.IllegalStateException: Missing header Content-Length in input " "but it has no effect in use. Why not show this error?"

jonahgraham commented 4 months ago

Can you provide additional information about how to reproduce this please? Or a sample trace that produces the issue you are experiencing.

linqingying123 commented 4 months ago

Sorry, the machine translation may not translate what I want to express, I mean in line 72 of org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer "if (headers.contentLength < 0) {. This.fireError (new IllegalStateException ("Missing header Content-Length in input\"+ debugBuilder +"\ ")). } else {. Boolean result = this.handleMessage (this.input, headers). If (! result) {. This.keepRunning = false. }.

NewLine = false. The this.fireError method called in "}" prints an error log (because the server did not send a complete message), and the error is displayed in intellij, but I do not want to show this error

jonahgraham commented 4 months ago

That error happens when the server sends an incomplete message, as you have concluded. But I don't know what change you want LSP4J to make. The error is logged, but if it is displayed in a way you don't like in intellij, should that be filled to intellij?

If I recall correctly you can extend and wire in your own subclass of StreamMessageProducer and in that subclass override fireError to have different behaviour.

linqingying123 commented 4 months ago

Thank you for reminding me that the project is too bloated and has forgotten how to write it before. I'm sorry I wasted your time.

jonahgraham commented 4 months ago

I assume the machine translation wrote that last message as I don't think it came across as you may have intended.

Closing for now as it seems there is nothing else for the LSP4J project to do here.