Closes https://github.com/spring-projects/spring-framework/issues/30398

Comment From: pivotal-cla

@rotilho Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

Comment From: pivotal-cla

@rotilho Thank you for signing the Contributor License Agreement!

Comment From: sdeleuze

Hi, thanks for this PR. As mentioned in #30398, we are waiting for the resolution of https://github.com/Kotlin/kotlinx.serialization/issues/253 to have this feature properly supported, including support for infinite streams.

Am I correct in understanding that your PR does not support infinite streams and may block the thread when processing big collections? If that's the case, I think I will decline since I prefer not giving the impression we support streams at programming level if we don't not properly support infinite streams and parsing big check of data without blocking.

Comment From: rotilho

Hey @sdeleuze! I saw that you mentioned the dependency on https://github.com/Kotlin/kotlinx.serialization/issues/253; however, after talking with @sandwwraith and after taking a closer look, I didn't find these limitations. Maybe I'm just missing something obvious, but the current implementation of kotlinx-serialization already supports decoding and encoding to stream. I considered changing the current implementation to use it, but since this is my first contribution, I was afraid to be too adventurous.

Answering your questions, the current implementation works with infinite streams, and I don't see any blocking occurring but I'll do more tests.

Edit: under load the coroutines just suspend, as expected.

Comment From: sdeleuze

Indeed, after a deeper look, we should be fine, and the new line delimitation ensures we have properly formed JSON object for each element.

Comment From: sdeleuze

Merged and polished, thanks for your contribution!