eclipse.jdt.ls
eclipse.jdt.ls copied to clipboard
Organize imports action throws exception
With latest versions of jdt.ls "organize imports" code action stopped working. Following exception observed in workspace .log
:
!ENTRY org.eclipse.jdt.ls.core 4 0 2024-01-26 16:29:18.250
!MESSAGE Failed to resolve organize imports source action
!STACK 0
org.eclipse.core.runtime.OperationCanceledException
at org.eclipse.jdt.core.manipulation.OrganizeImportsOperation.createTextEdit(OrganizeImportsOperation.java:626)
at org.eclipse.jdt.ls.core.internal.handlers.OrganizeImportsHandler.organizeImports(OrganizeImportsHandler.java:98)
at org.eclipse.jdt.ls.core.internal.text.correction.SourceAssistProcessor.getOrganizeImportsTextEdit(SourceAssistProcessor.java:354)
at org.eclipse.jdt.ls.core.internal.text.correction.SourceAssistProcessor.lambda$0(SourceAssistProcessor.java:141)
at org.eclipse.jdt.ls.core.internal.handlers.CodeActionResolveHandler.resolve(CodeActionResolveHandler.java:50)
at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$15(JDTLanguageServer.java:793)
at org.eclipse.jdt.ls.core.internal.BaseJDTLanguageServer.lambda$0(BaseJDTLanguageServer.java:87)
at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:646)
at java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:483)
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)
I'm using latest coc-java client.
Looks like it's happening at https://github.com/eclipse-jdt/eclipse.jdt.ui/blob/137f84f326ecb0e0b4663b634915e592b31c7cdc/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/OrganizeImportsOperation.java#L626 .
Do you have access to any logging information ? Maybe what the client / server are sending to eac h other when this happens ? Do you know what version of JDT-LS this still worked with ?
Seems like this issue happens only when there are several options for given import.
It works fine with jdt.ls 1.26.0
but fails with latest 1.31.0
:
Here are client logs for both versions:
Logs for jdt.ls 1.26.0
- OK
2024-01-30T13:49:18.864 INFO (pid:1311909) - [Trace - 13:49:18.864] Received response 'textDocument/codeAction - (10)' in 132ms.
2024-01-30T13:49:18.864 INFO (pid:1311909) - Result: [
{
"title": "Organize imports",
"kind": "source.organizeImports",
"diagnostics": [],
"data": {
"pid": "0",
"rid": "0"
}
}
]
2024-01-30T13:49:18.865 INFO (pid:1311909) - [Trace - 13:49:18.865] Sending request 'codeAction/resolve - (11)'.
2024-01-30T13:49:18.865 INFO (pid:1311909) - Params: {
"title": "Organize imports",
"kind": "source.organizeImports",
"diagnostics": [],
"data": {
"pid": "0",
"rid": "0"
}
}
2024-01-30T13:49:19.019 INFO (pid:1311909) - [Trace - 13:49:19.019] Received request 'workspace/executeClientCommand - (23)'.
2024-01-30T13:49:19.020 INFO (pid:1311909) - Params: {
"command": "java.action.organizeImports.chooseImports",
"arguments": [
"file:................",
[
{
"candidates": [
{
"fullyQualifiedName": "java.util.Arrays",
"id": "java.util.Arrays@-244455423"
},
{
"fullyQualifiedName": "org.assertj.core.util.Arrays",
"id": "org.assertj.core.util.Arrays@-2021472745"
},
{
"fullyQualifiedName": "org.assertj.core.internal.Arrays",
"id": "org.assertj.core.internal.Arrays@-975632254"
}
],
"range": {
"start": {
"line": 21,
"character": 88
},
"end": {
"line": 21,
"character": 94
}
}
}
],
false
]
}
2024-01-30T13:49:26.651 INFO (pid:1311909) - [Trace - 13:49:26.651] Sending response 'workspace/executeClientCommand - (23)'. Processing request took 7631ms
2024-01-30T13:49:26.651 INFO (pid:1311909) - Result: [
{
"fullyQualifiedName": "java.util.Arrays",
"id": "java.util.Arrays@-244455423"
}
]
2024-01-30T13:49:26.664 INFO (pid:1311909) - [Trace - 13:49:26.664] Received response 'codeAction/resolve - (11)' in 7799ms.
2024-01-30T13:49:26.664 INFO (pid:1311909) - Result: {
"title": "Organize imports",
"kind": "source.organizeImports",
"diagnostics": [],
"edit": {
"changes": {
"file:...........................": [
{
"range": {
"start": {
"line": 2,
"character": 0
},
"end": {
"line": 2,
"character": 0
}
},
"newText": "import java.util.Arrays;\n"
}
]
}
}
}
Logs for jdt.ls 1.31.0
- KO
2024-01-30T13:53:41.588 INFO (pid:1312665) - [Trace - 13:53:41.588] Received response 'textDocument/codeAction - (10)' in 169ms.
2024-01-30T13:53:41.588 INFO (pid:1312665) - Result: [
{
"title": "Organize imports",
"kind": "source.organizeImports",
"diagnostics": [],
"data": {
"pid": "0",
"rid": "0"
}
}
]
2024-01-30T13:53:41.589 INFO (pid:1312665) - [Trace - 13:53:41.589] Sending request 'codeAction/resolve - (11)'.
2024-01-30T13:53:41.589 INFO (pid:1312665) - Params: {
"title": "Organize imports",
"kind": "source.organizeImports",
"diagnostics": [],
"data": {
"pid": "0",
"rid": "0"
}
}
2024-01-30T13:53:41.753 INFO (pid:1312665) - [Trace - 13:53:41.753] Received notification 'window/logMessage'.
2024-01-30T13:53:41.753 INFO (pid:1312665) - Params: {
"type": 1,
"message": "Jan 30, 2024, 1:53:41 PM Failed to resolve organize imports source action\nnull\norg.eclipse.core.runtime.OperationCanceledException\n\tat org.eclipse.jdt.core.manipulation.OrganizeImportsOperation.createTextEdit(OrganizeImportsOperation.java:629)\n\tat org.eclipse.jdt.ls.core.internal.handlers.OrganizeImportsHandler.organizeImports(OrganizeImportsHandler.java:98)\n\tat org.eclipse.jdt.ls.core.internal.text.correction.SourceAssistProcessor.getOrganizeImportsTextEdit(SourceAssistProcessor.java:354)\n\tat org.eclipse.jdt.ls.core.internal.text.correction.SourceAssistProcessor.lambda$0(SourceAssistProcessor.java:141)\n\tat org.eclipse.jdt.ls.core.internal.handlers.CodeActionResolveHandler.resolve(CodeActionResolveHandler.java:50)\n\tat org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$15(JDTLanguageServer.java:793)\n\tat org.eclipse.jdt.ls.core.internal.BaseJDTLanguageServer.lambda$0(BaseJDTLanguageServer.java:87)\n\tat java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:646)\n\tat java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:483)\n\tat java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)\n\tat java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)\n\tat java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)\n\tat java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)\n\tat java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)\n"
}
2024-01-30T13:53:41.753 INFO (pid:1312665) - [Error - 13:53:41.753] Jan 30, 2024, 1:53:41 PM Failed to resolve organize imports source action
null
org.eclipse.core.runtime.OperationCanceledException
at org.eclipse.jdt.core.manipulation.OrganizeImportsOperation.createTextEdit(OrganizeImportsOperation.java:629)
at org.eclipse.jdt.ls.core.internal.handlers.OrganizeImportsHandler.organizeImports(OrganizeImportsHandler.java:98)
at org.eclipse.jdt.ls.core.internal.text.correction.SourceAssistProcessor.getOrganizeImportsTextEdit(SourceAssistProcessor.java:354)
at org.eclipse.jdt.ls.core.internal.text.correction.SourceAssistProcessor.lambda$0(SourceAssistProcessor.java:141)
at org.eclipse.jdt.ls.core.internal.handlers.CodeActionResolveHandler.resolve(CodeActionResolveHandler.java:50)
at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$15(JDTLanguageServer.java:793)
at org.eclipse.jdt.ls.core.internal.BaseJDTLanguageServer.lambda$0(BaseJDTLanguageServer.java:87)
at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:646)
at java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:483)
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)
2024-01-30T13:53:41.754 INFO (pid:1312665) - [Trace - 13:53:41.754] Received response 'codeAction/resolve - (11)' in 165ms.
2024-01-30T13:53:41.754 INFO (pid:1312665) - Result: {
"title": "Organize imports",
"kind": "source.organizeImports",
"diagnostics": []
}
Same issue with coc-java here too, for 1.33