Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public void startAsync() {
Assert.state(this.state == State.ASYNC, "Cannot start async: [" + this.state + "]");
}

this.asyncContext = getRequest().startAsync(getRequest(), getResponse());
this.asyncContext = getRequest().startAsync();
this.asyncContext.addListener(this);
if (this.timeout != null) {
this.asyncContext.setTimeout(this.timeout);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@

import java.util.function.Consumer;

import jakarta.servlet.AsyncContext;
import jakarta.servlet.AsyncEvent;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
Expand All @@ -31,6 +34,7 @@
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

/**
* Tests for {@link StandardServletAsyncWebRequest}.
Expand Down Expand Up @@ -79,6 +83,20 @@ void startAsync() {
assertThat(context.getListeners()).containsExactly(asyncRequest);
}

@Test
void startAsyncUsesContainerRequestAndResponse() {
HttpServletRequest request = mock(HttpServletRequest.class);
HttpServletResponse response = mock(HttpServletResponse.class);
AsyncContext asyncContext = mock(AsyncContext.class);
when(request.isAsyncSupported()).thenReturn(true);
when(request.startAsync()).thenReturn(asyncContext);
StandardServletAsyncWebRequest asyncRequest = new StandardServletAsyncWebRequest(request, response);

asyncRequest.startAsync();

verify(request).startAsync();
}

@Test
void startAsyncMultipleTimes() {
asyncRequest.startAsync();
Expand Down