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