Skip to content

Commit a072719

Browse files
committed
Polishing
1 parent 5ab1097 commit a072719

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ResponseBodyEmitter.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,21 @@ public class ResponseBodyEmitter {
7272
/** Store send data before handler is initialized. */
7373
private final Set<DataWithMediaType> earlySendAttempts = new LinkedHashSet<>(8);
7474

75-
/** Store complete invocation before handler is initialized. */
75+
/** Store successful completion before the handler is initialized. */
7676
private boolean complete;
7777

78-
/** Store completeWithError invocation before handler is initialized. */
78+
/** Store an error before the handler is initialized. */
7979
@Nullable
8080
private Throwable failure;
8181

8282
/**
83-
* After an IOException on send, the servlet container will provide an onError
84-
* callback that we'll handle as completeWithError (on container thread).
85-
* We use this flag to ignore competing attempts to completeWithError by
86-
* the application via try-catch. */
83+
* After an I/O error, we don't call {@link #completeWithError} directly but
84+
* wait for the Servlet container to call us via {@code AsyncListener#onError}
85+
* on a container thread at which point we call completeWithError.
86+
* This flag is used to ignore further calls to complete or completeWithError
87+
* that may come for example from an application try-catch block on the
88+
* thread of the I/O error.
89+
*/
8790
private boolean sendFailed;
8891

8992
private final DefaultCallback timeoutCallback = new DefaultCallback();
@@ -280,7 +283,10 @@ public String toString() {
280283

281284

282285
/**
283-
* Handle sent objects and complete request processing.
286+
* Contract to handle the sending of event data, the completion of event
287+
* sending, and the registration of callbacks to be invoked in case of
288+
* timeout, error, and completion for any reason (including from the
289+
* container side).
284290
*/
285291
interface Handler {
286292

0 commit comments

Comments
 (0)