title: Using Async-IO of servlet3.1 with Spring
body: <p><strong>How to use <code>Async-IO</code>(setWriteListener) of <code>Servlet3.1</code> with Spring-5 ?</strong></p>
  
  <p>Also, I found <a href="https://stackoverflow.com/questions/28828355/is-servlet-3-1-readwritelistener-supported-by-deferredresult-in-spring-4">Link-A</a> which mentions one needs to add Listener to outputStream.<br>
  On other hand <a href="https://dzone.com/articles/servlet-31spring-mvc-non-blocking-io" rel="nofollow noreferrer">Link-B</a> says it should work with <code>spring 5</code> and <code>tomcat 8.5+</code>.</p>
  
  <p>Next I profiled a JVM and found that <code>CoyoteOutputStream.checkNonBlockingWrite</code> always return <code>false</code> with both <code>deferredResult</code> and <code>NON-DeferredResult</code> sample code.</p>
  
  <pre><code> //MY TEST CODE  
   @GetMapping("/health")
      public DeferredResult&lt;DummyDTO&gt; upNRuning(){        
          DeferredResult&lt;DummyDTO&gt; defferedResult = new DeferredResult&lt;&gt;();
          newCachedThreadPool.submit(() -&gt;
              defferedResult.setResult(new DummyDTO()));
          return defferedResult;  
      }
  </code></pre>
  
  <p>I was not able to try <code>Link-A</code> recommandation as i am not sure of <code>NioReadListener</code> implementation and its arguments.</p>
  
  <hr>
  
  <p>PS:<br>
  Environment Spring-boot-2.0.4.RELEASE + Windows</p>