Make DeferredResult more usable and testable

DeferredResult now has a setErrorResult method that can be set to an
Exception or an error object, error view, etc.

The new isSetOrExpired() method can be used to check pro-actively if
the DeferredResult is still usable or not.

The setDeferredResultHandler method is now public so tests may use it.

Issue: SPR-9690, SPR-9689
This commit is contained in:
Rossen Stoyanchev
2012-08-16 00:12:23 -04:00
parent 3b9833c538
commit 4407f6a4c0
9 changed files with 190 additions and 218 deletions

View File

@@ -705,7 +705,7 @@ public class RequestMappingHandlerAdapter extends AbstractHandlerMethodAdapter i
if (logger.isDebugEnabled()) {
logger.debug("Found concurrent result value [" + result + "]");
}
requestMappingMethod = requestMappingMethod.wrapConcurrentProcessingResult(result);
requestMappingMethod = requestMappingMethod.wrapConcurrentResult(result);
}
requestMappingMethod.invokeAndHandle(webRequest, mavContainer);

View File

@@ -167,7 +167,7 @@ public class ServletInvocableHandlerMethod extends InvocableHandlerMethod {
* from an async operation essentially either applying return value handling or
* raising an exception if the end result is an Exception.
*/
ServletInvocableHandlerMethod wrapConcurrentProcessingResult(final Object result) {
ServletInvocableHandlerMethod wrapConcurrentResult(final Object result) {
return new CallableHandlerMethod(new Callable<Object>() {