MvcResult returns asyncResult after asyncDispatch
Issue: SPR-16648
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -62,7 +62,14 @@ public class MockAsyncContext implements AsyncContext {
|
||||
|
||||
public void addDispatchHandler(Runnable handler) {
|
||||
Assert.notNull(handler, "Dispatch handler must not be null");
|
||||
this.dispatchHandlers.add(handler);
|
||||
synchronized (this) {
|
||||
if (this.dispatchedPath == null) {
|
||||
this.dispatchHandlers.add(handler);
|
||||
}
|
||||
else {
|
||||
handler.run();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -92,9 +99,11 @@ public class MockAsyncContext implements AsyncContext {
|
||||
|
||||
@Override
|
||||
public void dispatch(ServletContext context, String path) {
|
||||
this.dispatchedPath = path;
|
||||
for (Runnable r : this.dispatchHandlers) {
|
||||
r.run();
|
||||
synchronized (this) {
|
||||
this.dispatchedPath = path;
|
||||
for (Runnable r : this.dispatchHandlers) {
|
||||
r.run();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user