Skip to content

Commit 9a76157

Browse files
committed
Remove ServerResponse.AsyncBuilder interface
This new interface is not strictly necessary and introduces a binary incompatibility. This commit merges back all the method definitions into `SseBuilder` and `StreamBuilder` interfaces. Closes gh-33736
1 parent 67c7b80 commit 9a76157

File tree

1 file changed

+46
-18
lines changed

1 file changed

+46
-18
lines changed

spring-webmvc/src/main/java/org/springframework/web/servlet/function/ServerResponse.java

Lines changed: 46 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -584,11 +584,11 @@ interface BodyBuilder extends HeadersBuilder<BodyBuilder> {
584584
}
585585

586586
/**
587-
* Defines a builder for async response bodies.
588-
* @since 6.2
589-
* @param <B> the builder subclass
587+
* Defines a builder for a body that sends server-sent events.
588+
*
589+
* @since 5.3.2
590590
*/
591-
interface AsyncBuilder<B extends AsyncBuilder<B>> {
591+
interface SseBuilder {
592592

593593
/**
594594
* Completes the stream with the given error.
@@ -611,32 +611,22 @@ interface AsyncBuilder<B extends AsyncBuilder<B>> {
611611
* @param onTimeout the callback to invoke on timeout
612612
* @return this builder
613613
*/
614-
B onTimeout(Runnable onTimeout);
614+
SseBuilder onTimeout(Runnable onTimeout);
615615

616616
/**
617617
* Register a callback to be invoked when an error occurs during
618618
* processing.
619619
* @param onError the callback to invoke on error
620620
* @return this builder
621621
*/
622-
B onError(Consumer<Throwable> onError);
622+
SseBuilder onError(Consumer<Throwable> onError);
623623

624624
/**
625625
* Register a callback to be invoked when the request completes.
626626
* @param onCompletion the callback to invoked on completion
627627
* @return this builder
628628
*/
629-
B onComplete(Runnable onCompletion);
630-
631-
}
632-
633-
634-
/**
635-
* Defines a builder for a body that sends server-sent events.
636-
*
637-
* @since 5.3.2
638-
*/
639-
interface SseBuilder extends AsyncBuilder<SseBuilder> {
629+
SseBuilder onComplete(Runnable onCompletion);
640630

641631
/**
642632
* Sends the given object as a server-sent event.
@@ -706,7 +696,45 @@ interface SseBuilder extends AsyncBuilder<SseBuilder> {
706696
*
707697
* @since 6.2
708698
*/
709-
interface StreamBuilder extends AsyncBuilder<StreamBuilder> {
699+
interface StreamBuilder {
700+
701+
/**
702+
* Completes the stream with the given error.
703+
*
704+
* <p>The throwable is dispatched back into Spring MVC, and passed to
705+
* its exception handling mechanism. Since the response has
706+
* been committed by this point, the response status can not change.
707+
* @param t the throwable to dispatch
708+
*/
709+
void error(Throwable t);
710+
711+
/**
712+
* Completes the stream.
713+
*/
714+
void complete();
715+
716+
/**
717+
* Register a callback to be invoked when a request times
718+
* out.
719+
* @param onTimeout the callback to invoke on timeout
720+
* @return this builder
721+
*/
722+
StreamBuilder onTimeout(Runnable onTimeout);
723+
724+
/**
725+
* Register a callback to be invoked when an error occurs during
726+
* processing.
727+
* @param onError the callback to invoke on error
728+
* @return this builder
729+
*/
730+
StreamBuilder onError(Consumer<Throwable> onError);
731+
732+
/**
733+
* Register a callback to be invoked when the request completes.
734+
* @param onCompletion the callback to invoked on completion
735+
* @return this builder
736+
*/
737+
StreamBuilder onComplete(Runnable onCompletion);
710738

711739
/**
712740
* Write the given object to the response stream, without flushing.

0 commit comments

Comments
 (0)