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 `workspace/diagnostic` #682

Closed pisv closed 1 year ago

pisv commented 1 year ago

I've just found this bug, which was supposed to be fixed as part of #668, but unfortunately it was not. JsonParseException: Ambiguous Either type: token BEGIN_OBJECT matches both alternatives is still thrown when reading a response to a workspace/diagnostic request.

The reason is that WorkspaceDocumentDiagnosticReportTypeAdapter was (erroneously) specified as @ResponseJsonAdapter for the WorkspaceService.diagnostic method, which actually returns a WorkspaceDiagnosticReport rather than a WorkspaceDocumentDiagnosticReport. I guess that this was unfortunate misreading caused by similarity in type names, since the wrong expected type was also used in the unit tests for parsing workspace/diagnostic response.

I'm preparing a PR to fix this.