From 6842fd7fb954e751fb6c310f7183527fd1876653 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Thu, 25 Jun 2015 05:01:39 -0400 Subject: [PATCH] Ensure result ready in asyncDispatch in MockMvc Issue: SPR-13079 --- .../test/web/servlet/request/MockMvcRequestBuilders.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/spring-test/src/main/java/org/springframework/test/web/servlet/request/MockMvcRequestBuilders.java b/spring-test/src/main/java/org/springframework/test/web/servlet/request/MockMvcRequestBuilders.java index c80f28b6555..3a707ac2e04 100644 --- a/spring-test/src/main/java/org/springframework/test/web/servlet/request/MockMvcRequestBuilders.java +++ b/spring-test/src/main/java/org/springframework/test/web/servlet/request/MockMvcRequestBuilders.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 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. @@ -221,6 +221,10 @@ public abstract class MockMvcRequestBuilders { * @param mvcResult the result from the request that started async processing */ public static RequestBuilder asyncDispatch(final MvcResult mvcResult) { + + // There must be an async result before dispatching + mvcResult.getAsyncResult(); + return new RequestBuilder() { @Override public MockHttpServletRequest buildRequest(ServletContext servletContext) {