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

Add support for JSON streams to Kotlin Serialization #32074

Closed
wants to merge 1 commit into from

Conversation

rotilho
Copy link
Contributor

@rotilho rotilho commented Jan 20, 2024

Closes #30398

@pivotal-cla
Copy link

@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.

@pivotal-cla
Copy link

@rotilho Thank you for signing the Contributor License Agreement!

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jan 20, 2024
@sdeleuze sdeleuze self-assigned this Jan 23, 2024
@sdeleuze sdeleuze added theme: kotlin An issue related to Kotlin support in: web Issues in web modules (web, webmvc, webflux, websocket) labels Jan 23, 2024
@sdeleuze
Copy link
Contributor

Hi, thanks for this PR. As mentioned in #30398, we are waiting for the resolution of Kotlin/kotlinx.serialization#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.

@sdeleuze sdeleuze added the status: waiting-for-feedback We need additional information before we can continue label Jan 23, 2024
@rotilho
Copy link
Contributor Author

rotilho commented Jan 23, 2024

Hey @sdeleuze! I saw that you mentioned the dependency on Kotlin/kotlinx.serialization#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.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Jan 23, 2024
@sdeleuze
Copy link
Contributor

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

@sdeleuze sdeleuze added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged or decided on status: feedback-provided Feedback has been provided labels Jan 24, 2024
@sdeleuze sdeleuze added this to the 6.1.4 milestone Jan 24, 2024
sdeleuze added a commit to sdeleuze/spring-framework that referenced this pull request Jan 24, 2024
@sdeleuze sdeleuze closed this in 11898da Jan 24, 2024
@sdeleuze
Copy link
Contributor

Merged and polished, thanks for your contribution!

@sdeleuze sdeleuze changed the title Add support for stream MediaTypes when using Kotlinx Serializer Add support for JSON streams to Kotlin Serialization Jan 24, 2024
izeye added a commit to izeye/spring-framework that referenced this pull request Mar 22, 2024
izeye added a commit to izeye/spring-framework that referenced this pull request Mar 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) theme: kotlin An issue related to Kotlin support type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add streaming support to Kotlin serialization codecs
4 participants