Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Self referencing data classes can't be serialized #37

Closed
thake opened this issue Mar 19, 2020 · 4 comments
Closed

Self referencing data classes can't be serialized #37

thake opened this issue Mar 19, 2020 · 4 comments
Labels
bug Something isn't working

Comments

@thake
Copy link
Member

thake commented Mar 19, 2020

The following self referencing data class leads to a stack overflow when trying to determine the schema for the associatedProduct field:
@Serializable data class Product(val id: String, val associatedProduct: Product?)

java.lang.StackOverflowError
at kotlin.text.StringsKt__StringsKt.findAnyOf$StringsKt__StringsKt(Strings.kt:897)
at kotlin.text.StringsKt__StringsKt.access$findAnyOf(Strings.kt:1)
at kotlin.text.StringsKt__StringsKt$rangesDelimitedBy$4.invoke(Strings.kt:1170)
at kotlin.text.StringsKt__StringsKt$rangesDelimitedBy$4.invoke(Strings.kt)
at kotlin.text.DelimitedRangesSequence$iterator$1.calcNext(Strings.kt:1098)
at kotlin.text.DelimitedRangesSequence$iterator$1.hasNext(Strings.kt:1127)
at kotlin.sequences.TransformingSequence$iterator$1.hasNext(Sequences.kt:176)
at kotlin.sequences.SequencesKt___SequencesKt.joinTo(_Sequences.kt:1882)
at kotlin.sequences.SequencesKt___SequencesKt.joinToString(_Sequences.kt:1904)
at kotlin.sequences.SequencesKt___SequencesKt.joinToString$default(_Sequences.kt:1903)
at kotlin.text.StringsKt__StringsJVMKt.replace(StringsJVM.kt:76)
at kotlin.text.StringsKt__StringsJVMKt.replace$default(StringsJVM.kt:75)
at com.sksamuel.avro4k.RecordNaming.(RecordNaming.kt:22)
at com.sksamuel.avro4k.RecordNaming$Companion.invoke(RecordNaming.kt:13)
at com.sksamuel.avro4k.schema.ClassSchemaFor.buildField(ClassSchemaFor.kt:50)
at com.sksamuel.avro4k.schema.ClassSchemaFor.dataClassSchema(ClassSchemaFor.kt:37)
at com.sksamuel.avro4k.schema.ClassSchemaFor.schema(ClassSchemaFor.kt:25)
at com.sksamuel.avro4k.schema.NullableSchemaFor.schema(SchemaFor.kt:124)
at com.sksamuel.avro4k.schema.ClassSchemaFor.buildField(ClassSchemaFor.kt:52)
at com.sksamuel.avro4k.schema.ClassSchemaFor.dataClassSchema(ClassSchemaFor.kt:37)
at com.sksamuel.avro4k.schema.ClassSchemaFor.schema(ClassSchemaFor.kt:25)
at com.sksamuel.avro4k.schema.NullableSchemaFor.schema(SchemaFor.kt:124)
at com.sksamuel.avro4k.schema.ClassSchemaFor.buildField(ClassSchemaFor.kt:52)
at com.sksamuel.avro4k.schema.ClassSchemaFor.dataClassSchema(ClassSchemaFor.kt:37)
at com.sksamuel.avro4k.schema.ClassSchemaFor.schema(ClassSchemaFor.kt:25)
at com.sksamuel.avro4k.schema.NullableSchemaFor.schema(SchemaFor.kt:124)
at com.sksamuel.avro4k.schema.ClassSchemaFor.buildField(ClassSchemaFor.kt:52)
at com.sksamuel.avro4k.schema.ClassSchemaFor.dataClassSchema(ClassSchemaFor.kt:37)
at com.sksamuel.avro4k.schema.ClassSchemaFor.schema(ClassSchemaFor.kt:25)
at com.sksamuel.avro4k.schema.NullableSchemaFor.schema(SchemaFor.kt:124)
at com.sksamuel.avro4k.schema.ClassSchemaFor.buildField(ClassSchemaFor.kt:52)
at com.sksamuel.avro4k.schema.ClassSchemaFor.dataClassSchema(ClassSchemaFor.kt:37)
at com.sksamuel.avro4k.schema.ClassSchemaFor.schema(ClassSchemaFor.kt:25)
at com.sksamuel.avro4k.schema.NullableSchemaFor.schema(SchemaFor.kt:124)
at com.sksamuel.avro4k.schema.ClassSchemaFor.buildField(ClassSchemaFor.kt:52)

@stale
Copy link

stale bot commented May 18, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label May 18, 2020
@thake
Copy link
Member Author

thake commented May 18, 2020

Still open

@stale stale bot removed the wontfix label May 18, 2020
@stale
Copy link

stale bot commented Jul 17, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jul 17, 2020
@stale stale bot closed this as completed Jul 24, 2020
@thake thake reopened this Nov 3, 2020
@thake thake added bug Something isn't working and removed wontfix labels Nov 3, 2020
@geomagilles
Copy link
Contributor

Proposed a PR: #78

@thake thake closed this as completed in aa13cfd Nov 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants