Fix failing test
This commit is contained in:
@@ -110,31 +110,33 @@ class DefaultMvcResult implements MvcResult {
|
||||
}
|
||||
|
||||
public Object getAsyncResult() {
|
||||
WebAsyncManager asyncManager = WebAsyncUtils.getAsyncManager(this.mockRequest);
|
||||
if (asyncManager.isConcurrentHandlingStarted()) {
|
||||
if (!awaitAsyncResult()) {
|
||||
HttpServletRequest request = this.mockRequest;
|
||||
if (request.isAsyncStarted()) {
|
||||
|
||||
long timeout = request.getAsyncContext().getTimeout();
|
||||
if (!awaitAsyncResult(timeout)) {
|
||||
throw new IllegalStateException(
|
||||
"Gave up waiting on async result from [" + this.handler + "] to complete");
|
||||
}
|
||||
|
||||
WebAsyncManager asyncManager = WebAsyncUtils.getAsyncManager(this.mockRequest);
|
||||
if (asyncManager.hasConcurrentResult()) {
|
||||
return asyncManager.getConcurrentResult();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean awaitAsyncResult() {
|
||||
if (this.asyncResultLatch == null) {
|
||||
return true;
|
||||
}
|
||||
long timeout = ((HttpServletRequest) this.mockRequest).getAsyncContext().getTimeout();
|
||||
try {
|
||||
return this.asyncResultLatch.await(timeout, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
return false;
|
||||
private boolean awaitAsyncResult(long timeout) {
|
||||
if (this.asyncResultLatch != null) {
|
||||
try {
|
||||
return this.asyncResultLatch.await(timeout, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -72,7 +72,6 @@ public class AsyncTests {
|
||||
public Callable<Person> getCallable() {
|
||||
return new Callable<Person>() {
|
||||
public Person call() throws Exception {
|
||||
Thread.sleep(100);
|
||||
return new Person("Joe");
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user