提交 fe77c3d5 编写于 作者: R Rossen Stoyanchev

Fix failing test

上级 e14ba9de
......@@ -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");
}
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册