title: How to simplify retry code block with java 8 features
body: <p>In my code I have a section which tries to connect to some external interface, if it fails, then it will retry it a fixed number of times. The code works, but is somewhat ugly. I am wondering whether this can be done in a more elegant way using some fancy Java8 features?</p>
  
  <pre><code>int count = 0;
  final int maxRetries = 3;
  while ( count &lt; maxRetries )
  {
     try
     {
       // Some Code
       // break out of loop on success
     }
     catch ( final ExecutionException e )
     {
        LOG.debug( "retrying..." );
        if ( ++count &gt;= maxRetries )
        {
           LOG.debug( "do something else...");
           //do something else
        }
     }
  }
  </code></pre>