title: Recursive call in try-catch block to retry N number of times
body: <p>I have a regular, non-static <code>sendMail</code> method which may occasionally fail. I need to catch any errors and retry the method N number of times. I'm not sure I'm doing the right thing, and there's also a compilation error:</p>
  
  <pre><code>public void sendMail(List&lt;String&gt; params) {
  
     try {
         //...
  
         static int retrycount = 0; // static not allowed here (but need to keep static var for recursion)
         int maxretries = 3;
     }
     catch (Exception e) {
         log.info(e);
         // Recursion to retry
         sendMail(params);
         retrycount++;
     }
  }
  </code></pre>
  
  <p>First of all, is recursion from a try/catch block correct? Also, is there a better way to do this?</p>
  
  <p>I can't make the <code>sendMail</code> method static, there are too many references to it in the existing code.</p>