Repository navigation
Closed
Labels
Milestone
Description
Under certain conditions (I will try to reproduce the code snippet that I used when I ran into this), selecting a bean completion proposal causes this on the language server side:
13:54:30.383 [ForkJoinPool.commonPool-worker-1] ERROR o.s.i.v.c.rewrite.java.ORAstUtils -
java.lang.ClassCastException: class com.sun.tools.javac.tree.JCTree$JCExpressionStatement cannot be cast to class com.sun.tools.javac.tree.JCTree$JCVariableDecl (com.sun.tools.javac.tree.JCTree$JCExpressionStatement and com.sun.tools.javac.tree.JCTree$JCVariableDecl are in unnamed module of loader org.openrewrite.java.JavaUnrestrictedClassLoader @62839bf)
at org.openrewrite.java.isolated.ReloadableJava21ParserVisitor.visitVariables(ReloadableJava21ParserVisitor.java:1554)
at org.openrewrite.java.isolated.ReloadableJava21ParserVisitor.convertStatements(ReloadableJava21ParserVisitor.java:1910)
at org.openrewrite.java.isolated.ReloadableJava21ParserVisitor.convertStatements(ReloadableJava21ParserVisitor.java:1879)
at org.openrewrite.java.isolated.ReloadableJava21ParserVisitor.visitBlock(ReloadableJava21ParserVisitor.java:326)
at org.openrewrite.java.isolated.ReloadableJava21ParserVisitor.visitBlock(ReloadableJava21ParserVisitor.java:77)
at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1104)
at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:92)
at org.openrewrite.java.isolated.ReloadableJava21ParserVisitor.convert(ReloadableJava21ParserVisitor.java:1699)
at org.openrewrite.java.isolated.ReloadableJava21ParserVisitor.convertOrNull(ReloadableJava21ParserVisitor.java:1780)
at org.openrewrite.java.isolated.ReloadableJava21ParserVisitor.visitMethod(ReloadableJava21ParserVisitor.java:1020)
at org.openrewrite.java.isolated.ReloadableJava21ParserVisitor.visitMethod(ReloadableJava21ParserVisitor.java:77)
at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:948)
at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:92)
at org.openrewrite.java.isolated.ReloadableJava21ParserVisitor.convert(ReloadableJava21ParserVisitor.java:1699)
at org.openrewrite.java.isolated.ReloadableJava21ParserVisitor.convert(ReloadableJava21ParserVisitor.java:1735)
at org.openrewrite.java.isolated.ReloadableJava21ParserVisitor.convertStatements(ReloadableJava21ParserVisitor.java:1901)
at org.openrewrite.java.isolated.ReloadableJava21ParserVisitor.convertStatements(ReloadableJava21ParserVisitor.java:1879)
at org.openrewrite.java.isolated.ReloadableJava21ParserVisitor.visitClass(ReloadableJava21ParserVisitor.java:520)
at org.openrewrite.java.isolated.ReloadableJava21ParserVisitor.visitClass(ReloadableJava21ParserVisitor.java:77)
at com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:855)
at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:92)
at org.openrewrite.java.isolated.ReloadableJava21ParserVisitor.convert(ReloadableJava21ParserVisitor.java:1699)
at org.openrewrite.java.isolated.ReloadableJava21ParserVisitor.convertAll(ReloadableJava21ParserVisitor.java:1790)
at org.openrewrite.java.isolated.ReloadableJava21ParserVisitor.visitCompilationUnit(ReloadableJava21ParserVisitor.java:564)
at org.openrewrite.java.isolated.ReloadableJava21ParserVisitor.visitCompilationUnit(ReloadableJava21ParserVisitor.java:77)
at com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:623)
at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:92)
at org.openrewrite.java.isolated.ReloadableJava21Parser.lambda$parseInputs$0(ReloadableJava21Parser.java:166)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1939)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
at org.springframework.ide.vscode.commons.rewrite.java.ORAstUtils.parseInputs(ORAstUtils.java:332)
at org.springframework.ide.vscode.boot.java.rewrite.RewriteRefactorings.lambda$4(RewriteRefactorings.java:143)
at java.base/java.util.concurrent.CompletableFuture$UniCompose.tryFire(CompletableFuture.java:1150)
at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510)
at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1773)
at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1760)
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1312)
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1843)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1808)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:188)
13:54:30.383 [ForkJoinPool.commonPool-worker-1] ERROR o.e.lsp4j.jsonrpc.RemoteEndpoint - Internal error: java.lang.ClassCastException: Cannot cast org.openrewrite.tree.ParseError to org.openrewrite.java.tree.J$CompilationUnit
java.util.concurrent.CompletionException: java.lang.ClassCastException: Cannot cast org.openrewrite.tree.ParseError to org.openrewrite.java.tree.J$CompilationUnit
at java.base/java.util.concurrent.CompletableFuture.encodeRelay(CompletableFuture.java:368)
at java.base/java.util.concurrent.CompletableFuture.completeRelay(CompletableFuture.java:377)
at java.base/java.util.concurrent.CompletableFuture$UniRelay.tryFire(CompletableFuture.java:1097)
at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510)
at java.base/java.util.concurrent.CompletableFuture.completeExceptionally(CompletableFuture.java:2194)
at reactor.core.publisher.MonoToCompletableFuture.onError(MonoToCompletableFuture.java:77)
at reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onError(FluxOnAssembly.java:544)
at reactor.core.publisher.MonoFlatMap$FlatMapMain.onError(MonoFlatMap.java:180)
at reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onError(FluxOnAssembly.java:544)
at reactor.core.publisher.MonoCompletionStage$MonoCompletionStageSubscription.apply(MonoCompletionStage.java:115)
at reactor.core.publisher.MonoCompletionStage$MonoCompletionStageSubscription.apply(MonoCompletionStage.java:67)
at java.base/java.util.concurrent.CompletableFuture.uniHandle(CompletableFuture.java:934)
at java.base/java.util.concurrent.CompletableFuture$UniHandle.tryFire(CompletableFuture.java:911)
at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510)
at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1773)
at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1760)
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1312)
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1843)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1808)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:188)
Caused by: java.lang.ClassCastException: Cannot cast org.openrewrite.tree.ParseError to org.openrewrite.java.tree.J$CompilationUnit
at java.base/java.lang.Class.cast(Class.java:4067)
Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException:
Assembly trace from producer [reactor.core.publisher.MonoCompletionStage] :
reactor.core.publisher.Mono.fromFuture(Mono.java:629)
org.springframework.ide.vscode.boot.java.rewrite.RewriteRefactorings.createEdits(RewriteRefactorings.java:91)
Error has been observed at the following site(s):
*__Mono.fromFuture ⇢ at org.springframework.ide.vscode.boot.java.rewrite.RewriteRefactorings.createEdits(RewriteRefactorings.java:91)
|_ Mono.flatMap ⇢ at org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer.executeCommand(SimpleLanguageServer.java:321)
Original Stack Trace:
at java.base/java.lang.Class.cast(Class.java:4067)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1939)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
at org.springframework.ide.vscode.commons.rewrite.java.ORAstUtils.parseInputs(ORAstUtils.java:332)
at org.springframework.ide.vscode.boot.java.rewrite.RewriteRefactorings.lambda$4(RewriteRefactorings.java:143)
at java.base/java.util.concurrent.CompletableFuture$UniCompose.tryFire(CompletableFuture.java:1150)
at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510)
at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1773)
at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1760)
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1312)
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1843)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1808)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:188)
On the client side (Eclipse in this case), just nothing happens, just the task is continue to run (endlessly) in the progress view.
Activity
BoykoAlex commentedon Mar 17, 2025
The stack trace hints at an issue with parsing java source with errors... Likely a case we are missing with erroneous node.
martinlippert commentedon Mar 19, 2025
🤔 Seems to be difficult to reproduce, tried various things but wasn't able to get to this exception reliably. I've seen it again, but wasn't able to capture the exact code that produced it. Need to investigate this further.
martinlippert commentedon Mar 19, 2025
One thing that I observed though is that once this exception happens, VSCode shows an error popup and the progress continues to be displayed (so the client things that this operation hasn't finished yet), so it would be good to avoid that endless progress display if things like this happen.
martinlippert commentedon Mar 26, 2025
I tried again, but I can't reproduce this anymore. So we should focus on the generic "avoid showing the progress endlessly if something like this happens" aspect here - in case this is possible to solve without reproducing the issue. Maybe we can inject an artificial exception somewhere to reproduce at least the rest of the behavior (the endless progress).
[-][bean completion proposals] selecting completion proposal causes exception in language server[/-][+]stop showing progress when exception happens deep inside the language server[/+]BoykoAlex commentedon Apr 3, 2025
We can try add a utility method to progress service:
Or just deal with each case individually... as task might be needed while future is exdecuted to update the message etc. This case in
RewriteRefactoringsis rather straight-forward and can be dealt with at theRewriteRefactoringsclass level...martinlippert commentedon Apr 4, 2025
I don't have a strong preference here, whatever you think works best.
BoykoAlex commentedon Apr 4, 2025
Lets just fix it in the
RewriteRefactoringswith e5db6b3