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
613 stars 145 forks source link

`JsonParseException: Ambiguous Either type` when reading response to `textDocument/diagnostic` #668

Closed pisv closed 2 years ago

pisv commented 2 years ago

Looks like a type adapter is missing:

SEVERE: Ambiguous Either type: token BEGIN_OBJECT matches both alternatives.
com.google.gson.JsonParseException: Ambiguous Either type: token BEGIN_OBJECT matches both alternatives.
    at org.eclipse.lsp4j.jsonrpc.json.adapters.EitherTypeAdapter.create(EitherTypeAdapter.java:193)
    at org.eclipse.lsp4j.jsonrpc.json.adapters.EitherTypeAdapter.read(EitherTypeAdapter.java:177)
    at org.eclipse.lsp4j.jsonrpc.json.adapters.EitherTypeAdapter.read(EitherTypeAdapter.java:40)
    at com.google.gson.Gson.fromJson(Gson.java:991)
    at org.eclipse.lsp4j.jsonrpc.json.adapters.MessageTypeAdapter.fromJson(MessageTypeAdapter.java:329)
    at org.eclipse.lsp4j.jsonrpc.json.adapters.MessageTypeAdapter.parseResult(MessageTypeAdapter.java:188)
    at org.eclipse.lsp4j.jsonrpc.json.adapters.MessageTypeAdapter.read(MessageTypeAdapter.java:123)
    at org.eclipse.lsp4j.jsonrpc.json.adapters.MessageTypeAdapter.read(MessageTypeAdapter.java:55)
    at com.google.gson.Gson.fromJson(Gson.java:991)
    at org.eclipse.lsp4j.jsonrpc.json.MessageJsonHandler.parseMessage(MessageJsonHandler.java:119)
    at org.eclipse.lsp4j.jsonrpc.json.MessageJsonHandler.parseMessage(MessageJsonHandler.java:114)
    at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:193)
    at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)
    at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)
pisv commented 2 years ago

This bug is a stumbling block for implementing the new diagnostic pull model in clients using LSP4J. It would be nice if we could release the fix sooner rather than later.

jonahgraham commented 2 years ago

This bug is a stumbling block for implementing the new diagnostic pull model in clients using LSP4J. It would be nice if we could release the fix sooner rather than later.

Ack in: https://github.com/eclipse/lsp4j/issues/654#issuecomment-1263954495