Fix MultiPartServletTest race. (#9629)
The writing of the large content may see an EofException before the 400 response has been processed and delivered to the listener.
This commit is contained in:
parent
98c1fe24a2
commit
10abcbcf8e
|
@ -23,6 +23,7 @@ import java.nio.file.Path;
|
|||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
|
@ -256,9 +257,18 @@ public class MultiPartServletTest
|
|||
|
||||
assertThat(writeError, instanceOf(EofException.class));
|
||||
|
||||
// We should get 400 response, for some reason reading the content throws EofException.
|
||||
Response response = listener.get(30, TimeUnit.SECONDS);
|
||||
assertThat(response.getStatus(), equalTo(HttpStatus.BAD_REQUEST_400));
|
||||
// There is a race here, either we fail trying to write some more content OR
|
||||
// we get 400 response, for some reason reading the content throws EofException.
|
||||
try
|
||||
{
|
||||
Response response = listener.get(30, TimeUnit.SECONDS);
|
||||
assertThat(response.getStatus(), equalTo(HttpStatus.BAD_REQUEST_400));
|
||||
}
|
||||
catch (ExecutionException e)
|
||||
{
|
||||
Throwable cause = e.getCause();
|
||||
assertThat(cause, instanceOf(EofException.class));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.nio.file.Path;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
|
@ -273,9 +274,18 @@ public class MultiPartServletTest
|
|||
|
||||
assertThat(writeError, instanceOf(EofException.class));
|
||||
|
||||
// We should get 400 response, for some reason reading the content throws EofException.
|
||||
Response response = listener.get(30, TimeUnit.SECONDS);
|
||||
assertThat(response.getStatus(), equalTo(HttpStatus.BAD_REQUEST_400));
|
||||
// There is a race here, either we fail trying to write some more content OR
|
||||
// we get 400 response, for some reason reading the content throws EofException.
|
||||
try
|
||||
{
|
||||
Response response = listener.get(30, TimeUnit.SECONDS);
|
||||
assertThat(response.getStatus(), equalTo(HttpStatus.BAD_REQUEST_400));
|
||||
}
|
||||
catch (ExecutionException e)
|
||||
{
|
||||
Throwable cause = e.getCause();
|
||||
assertThat(cause, instanceOf(EofException.class));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue