0

I have a REST Controller, implemented using Spring MVC. The controller sets the DeferredResult setResult method with the response received after validations, from the service method.

df.setResult(responseobj);

However, the worker thread is not notified immediately after setting the response and my response is delayed. Using the Chrome debugger I get the below message under the "Network" Tab, against my REST call.

"Caution: request is not finished yet"

However, after a wait of 2 minutes, the status updates to "200" and the response is shown.

Saurav Ojha
  • 145
  • 1
  • 1
  • 7
  • There is no `setResponse` method in Spring [DeferredResult class](https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/context/request/async/DeferredResult.html). Are you sure about the method you are using? – Ilya Feb 07 '19 at 09:11
  • Sorry, Have edited my question now. It's setResult instead of setResponse. – Saurav Ojha Feb 07 '19 at 09:23
  • What is the returned value by `setResult` method? – Ilya Feb 07 '19 at 09:55
  • The return is a boolean "true", which come right after that line of code it hit. My screen waits another 2 minutes to show the result. – Saurav Ojha Feb 07 '19 at 10:39
  • It's hard to say without seeing the code, if you may upload sources of this case to github or another place I may try to help you. – Ilya Feb 07 '19 at 11:35
  • I am bound by company policies and can't post my code snippet online. However, there is one thing that I have realized. My setResult() is called from inside a run method. Could that be causing some issue? – Saurav Ojha Feb 07 '19 at 12:06

0 Answers0