title: CompletableFuture recursion for reliability
body: <p>This is very basic recursion for <code>CompletableFuture</code>, I want to make reliable system so each time got exception to restart process again, I'm believing it has too much issues and want to get your feedback about it </p>
  
  <pre><code>private CompletableFuture&lt;?&gt; recursion() {
  return CompletableFuture.runAsync(() -&gt; {
      //code here
      }).handleAsync((v, th) -&gt; {
          if (th != null)
              return this.recursion();
          else
              return v;
      });
  }
  </code></pre>
  
  <p>Edit1: </p>
  
  <pre><code>int tries =5;
  private CompletableFuture&lt;?&gt; recursion() {
      return CompletableFuture.runAsync(() -&gt; {
      //code here
      }).handleAsync((v, th) -&gt; {
          if (th != null &amp;&amp; tries-- &gt; 0){
              Thread.sleep(1000);
              return this.recursion();
          }else
              return v;
      });
  }
  </code></pre>
  
  <p>Edit2:
  cleaning code as the return  <code>CompletableFuture&lt;?&gt;</code> has no need so hanged it to be returning <code>void</code> considering @Holger comment and using AtomicInteger for tries</p>
  
  <pre><code>AtomicInteger tries =5;
  private void recursion() {
      CompletableFuture.runAsync(() -&gt; {
      //code here
      }).whenCompleteAsync((v, th) -&gt; {
          if (th != null &amp;&amp; ( tries.getAndDecrement() &gt; 0 ) ){
              Thread.sleep(1000);
              this.recursion();
          });
  }
  </code></pre>
  
  <p>please send me you feedback,I'm arguing but really appreciate it.</p>