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

DataBufferUtils and BodyInserters: allow consumers of OutputStream to throw IOException #33830

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

fedpet
Copy link

@fedpet fedpet commented Oct 31, 2024

At the moment, users of DataBufferUtils.outputStreamPublisher are forced to catch and re-throw IOException whenever they actually write to the OutputStream.

Example:

DataBufferUtils.outputStreamPublisher(
    outputStream -> {
        try {
            outputStream.write(1);
            ...
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    },
new DefaultDataBufferFactory(),
Runnable::run)

This PR aims to allow users to write cleaner code, example:

DataBufferUtils.outputStreamPublisher(
    outputStream -> {
        outputStream.write(1);
        ...
    },
new DefaultDataBufferFactory(),
Runnable::run)

As exceptions are already handled nicely under the hoods.

Same concept for BodyInserters.

@pivotal-cla
Copy link

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

@fedpet 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 Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-triage An issue we've not yet triaged or decided on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants