Response body is empty when using DeferredResult with Java Config.
Controller:
@Controller
public class HomeController {
@RequestMapping("/")
public DeferredResult<ModelAndView> home() {
final DeferredResult<ModelAndView> result = new DeferredResult<>();
Timer timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
result.setResult(new ModelAndView("home", Collections.singletonMap("name", "World")));
}
}, 2);
return result;
}
}
Configuration:
@Configuration
@ComponentScan(basePackages = "to.talk.gzip.test")
@PropertySource(value = "classpath:/application.properties")
@EnableWebMvc
public class AppConfig {
@Bean
public ViewResolver mustacheViewResolver() {
MustacheViewResolver resolver = new MustacheViewResolver();
resolver.setPrefix("views/");
resolver.setSuffix(".html");
return resolver;
}
}
Does it work without using a DeferredResult? I.e.
If that doesn't work, it may be a view related issue. If it does, then enable debug logging on or.springframework.web and look at the output for more clues. And/or add some logging of your own.
This seems to be a bug in Jetty 9. It works with Jetty 8.
Reported an issue: https://bugs.eclipse.org/bugs/show_bug.cgi?id=408117