Skip to content

A StackOverFlow error for serializable Kotlin data class for autocompletion in the Eclipse IDE #693

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
Daogreen opened this issue Oct 11, 2021 · 3 comments

Comments

@Daogreen
Copy link

Daogreen commented Oct 11, 2021

Describe the bug
I have a Spring Maven application based on the Eclipse IDE. The application contains several plug-in fragments. These fragments use properties files (see below). I use STS 4 of version 4.21.

I have a Kotlin file for configuration properties:
file FoobarConnectProperties.kt:
@Component @ConfigurationProperties(prefix = "foobar.connect") data class FoobarConnectProperties(var host: String = "", var port: Int = 8081) { var project: MutableMap<String, MySecurityProperties> = mutableMapOf() }

Also, I have another Kotlin file with properties (in a different package):
file MySecurityProperties.kt:
@kotlinx.serialization.Serializable data class MySecurityProperties(var user: String, var password: String, var useOAuth: Boolean)

To Reproduce
Run the application. Open the application.yml file. For foobar.connect.project properties try to make an auto-complete (by pressing Ctrl+Space). This auto-completion attempt gives a StackOverFlow error and shows "No proposals" for the given property as a result:

Oct 10, 2021 3:27:48 PM org.eclipse.lsp4j.jsonrpc.RemoteEndpoint fallbackResponseError SEVERE: Internal error: java.lang.StackOverflowError java.util.concurrent.CompletionException: java.lang.StackOverflowError at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:314) at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:319) at java.base/java.util.concurrent.CompletableFuture$UniAccept.tryFire(CompletableFuture.java:718) at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:506) at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1705) at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1692) at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290) at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020) at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656) at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594) at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183) Caused by: java.lang.StackOverflowError at java.base/java.lang.StringBuffer.append(StringBuffer.java:312) at java.base/java.io.StringWriter.write(StringWriter.java:106) at java.base/java.io.StringWriter.append(StringWriter.java:150) at java.base/java.io.StringWriter.append(StringWriter.java:41) at com.google.gson.stream.JsonWriter.beforeValue(JsonWriter.java:650) at com.google.gson.stream.JsonWriter.open(JsonWriter.java:326) at com.google.gson.stream.JsonWriter.beginObject(JsonWriter.java:309) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.write(ReflectiveTypeAdapterFactory.java:240) at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRuntimeTypeWrapper.java:69) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.write(ReflectiveTypeAdapterFactory.java:127) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.write(ReflectiveTypeAdapterFactory.java:245) at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRuntimeTypeWrapper.java:69) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.write(ReflectiveTypeAdapterFactory.java:127) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.write(ReflectiveTypeAdapterFactory.java:245) ...

If a Kotlin data class with properties is not annotated as Serializable, then everything works just fine without errors.

UPD: In STS3 it works without errors.

@martinlippert
Copy link
Member

Hey @Daogreen, can you please share a complete sample project that we could use to reproduce this? That would be awesome. Many many many thanks in advance!!!

@Daogreen
Copy link
Author

Daogreen commented Oct 18, 2021

Hello, @martinlippert ! Sorry for the late response.
You can find a sample project here - https://github.com/Daogreen/spring-maven-sample-project.

To reproduce:

  1. Import a Maven app project into the Eclipse IDE.
  2. Add propeties project to a build path.
  3. Open application.yml file and add the following properties and click Ctrl+Spacebar for autocompletion:
  foo:
     bar:
       host: example.com
       format:
         trim: false
       security: 

For the foo:bar:security properties it shows "No proposals" message and gives

[t=1634537564975] LSP4E to org.eclipse.languageserver.languages.springboot: {"jsonrpc":"2.0","id":"1210","error":{"code":-32603,"message":"Internal error.","data":"java.util.concurrent.CompletionException:...

It happens only if a Kotlin data class with properties is annotated as @serializable, without this annotation it works fine.

Please, let me know if you need additional information.

@martinlippert
Copy link
Member

Thanks to the sample project and the great description of what exactly to do, I was able to reproduce this error and debug it nicely. Found the issue, this is fixed now for the upcoming STS 4.13.0.RELEASE (coming up next week).

Thanks again @Daogreen for filing this bug report with all those details and the sample project, much appreciated, and of great help. Many many thanks!!!

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

3 participants