Skip to content

[refactoring] converting a simple rest service guide to Spring Boot 3 fails #867

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
martinlippert opened this issue Nov 4, 2022 · 9 comments
Assignees
Labels
for: eclipse something that is specific for Eclipse theme: refactoring type: bug

Comments

@martinlippert
Copy link
Member

Converting a standard Rest Service guide to Spring Boot 3 using the OpenRewrite recipes fails with:

  • (1) an exception:
java.lang.reflect.InvocationTargetException
	at org.springframework.tooling.boot.ls.commands.RewriteRefactoringsHandler.lambda$10(RewriteRefactoringsHandler.java:133)
	at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:122)
Caused by: java.util.concurrent.ExecutionException: org.eclipse.lsp4j.jsonrpc.ResponseErrorException: Internal error.
	at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:396)
	at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2073)
	at org.springframework.tooling.boot.ls.commands.RewriteRefactoringsHandler.lambda$10(RewriteRefactoringsHandler.java:130)
	... 1 more
Caused by: org.eclipse.lsp4j.jsonrpc.ResponseErrorException: Internal error.
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleResponse(RemoteEndpoint.java:209)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:193)
	at org.eclipse.lsp4e.LanguageServerWrapper.lambda$3(LanguageServerWrapper.java:286)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:194)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)
	at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:833)

The language server output doesn't show anything, no exception and no other error message related to this.

  • (2) the conversion is not complete, the Spring Boot version is not upgraded (probably due to a missing maven repo for milestones/snapshots)
@BoykoAlex
Copy link
Contributor

Yes, I noticed this briefly while upgrading petclinic to 3.0. Thought about giving 4.16.1 a -1 because of this but then I stopped seeing this error and no else from those testing the build complained. If I can reproduce this reliably with Rest Service Guide I'd be happy to get to the bottom of this.

@BoykoAlex
Copy link
Contributor

BoykoAlex commented Nov 7, 2022

@martinlippert did you have POM file opened while upgrading? If yes, switch off XML Language Server and try again I suspect that the errors might go away... Also before bringing up the rewrite recipes selector dialog project contents need to be saved - I'll address this.

@martinlippert
Copy link
Member Author

Yes, that indeed makes the error go away, but I am wondering what exactly triggers this error. Will look more into this, I guess.

@martinlippert
Copy link
Member Author

This seems to be the error message that causes the exception:

[t=1668968235533] org.eclipse.wildwebdeveloper.xml to LSP4E:
{"jsonrpc":"2.0","id":"10","error":{"code":-32603,"message":"Internal error.","data":"java.lang.RuntimeException: java.lang.reflect.InvocationTargetException\n\tat org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:67)\n\tat org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.request(GenericEndpoint.java:120)\n\tat org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleRequest(RemoteEndpoint.java:261)\n\tat org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:190)\n\tat org.eclipse.lemminx.commons.ParentProcessWatcher.lambda$apply$0(ParentProcessWatcher.java:143)\n\tat org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:194)\n\tat org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)\n\tat org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)\n\tat java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)\n\tat java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)\n\tat java.base/java.lang.Thread.run(Thread.java:833)\nCaused by: java.lang.reflect.InvocationTargetException\n\tat java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n\tat java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)\n\tat java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n\tat java.base/java.lang.reflect.Method.invoke(Method.java:568)\n\tat org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:65)\n\t... 12 more\nCaused by: org.eclipse.lsp4j.jsonrpc.ResponseErrorException: No command handler for the command: sts/rewrite/execute\n\tat org.eclipse.lemminx.XMLWorkspaceService.executeCommand(XMLWorkspaceService.java:55)\n\t... 17 more\n"}}

It looks like the command to execute the rewrite recipes is being sent to the XML language server:

[t=1668968235481] LSP4E to org.eclipse.wildwebdeveloper.xml:
{"jsonrpc":"2.0","id":"10","method":"workspace/executeCommand","params":{"command":"sts/rewrite/execute","arguments":...

@martinlippert
Copy link
Member Author

In addition that it looks to me like the message that is being sent to the language server to execute the command is extremely long (more than 500k (!)). So it looks like we need to investigate why this message is being sent to the XML language server and why this message is so long.

@BoykoAlex
Copy link
Contributor

@martinlippert good finds... I think I understand why the command goes out to XML LS when pom is opened. I think it is because of this:

				List<@NonNull LanguageServer> usedLanguageServers = LanguageServiceAccessor
						.getActiveLanguageServers(serverCapabilities -> true);

Instead i plan to use LanguageServerRegistry to find the LS definition for id and then find the exact language server wrapper with the help of LanguageServerWrapper getLSWrapper(IProject project, LanguageServerDefinition serverDefinition) find the exact boot ls wrapper and if it's active execute the command on just that language server.

The long message issue... this is due to me sending recipe descriptors for the selected recipes... Recipe descriptor is ane exact data required to create a recipe on the server side, i.e description, name, parameters. Although i think 500Kb is a bit too much even for this data...

@BoykoAlex
Copy link
Contributor

I limited command execution only to Boot LS with this: dd2f60a
If 500Kb JSON parameter for the command can go to a separate issue (seems lower priority) then we try closing this one

@martinlippert
Copy link
Member Author

I created a new issue for the message size issue: #897

@martinlippert
Copy link
Member Author

Tested this with the latest nightly build, looks great. Closing this one as fixed.

@martinlippert martinlippert added the for: eclipse something that is specific for Eclipse label Nov 21, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
for: eclipse something that is specific for Eclipse theme: refactoring type: bug
Projects
None yet
Development

No branches or pull requests

2 participants