mscheong01 / krotoDC

Protobuf Kotlin Dataclass, Converter & Custom Kotlin Coroutine gRPC Generator
Apache License 2.0
92 stars 8 forks source link

demonstrate recursion and stackoverflow error #19

Open Dogacel opened 1 year ago

mscheong01 commented 1 year ago

Hi @Dogacel, What do you think should be the expected output when recursive proto messages are defined? With our current API, this stackoverflowerror seems inevitable, unless #9 is implemented

Dogacel commented 1 year ago

Hi @Dogacel, What do you think should be the expected output when recursive proto messages are defined? With our current API, this stackoverflowerror seems inevitable, unless #9 is implemented

Technically, a recursive proto message is never serializable thus I see two options other than #9:

  1. Error during code-generation for never serializable / initiliazible objects.
  2. Automatically infer nullability for recursive objects.

The error I demonstrate should be the last resort, in my personal opinion, I think users should know this beforehand either by seeing the nullable type of getting an error during code-generation. For example you can allow skipping erroneous code.