title: Handle only custom exception in spring retry
body: <p>I want to retry only custom exceptions in Spring retry. But retryTemplate retries all exceptions. My code:</p>
  
  <pre><code>    try {
              getRetryTemplate().execute((RetryCallback&lt;Void, IOException&gt;) context -&gt; {
  
                  throw new RuntimeException("ddd"); // don't need to retry
              });
          } catch (IOException e) {
              log.error("");
          } catch (Throwable throwable) {
              log.error("Error .", throwable); // I want catch exception after first attempt
          }
  
  private RetryTemplate getRetryTemplate() {
          RetryTemplate retryTemplate = new RetryTemplate();
  
          ExponentialBackOffPolicy exponentialBackOffPolicy = new ExponentialBackOffPolicy();
          exponentialBackOffPolicy.setInitialInterval(INITIAL_INTERVAL_FOR_RETRYING);
          retryTemplate.setBackOffPolicy(exponentialBackOffPolicy);
  
          SimpleRetryPolicy retryPolicy = new SimpleRetryPolicy();
          retryPolicy.setMaxAttempts(MAX_ATTEMPTS);
          retryTemplate.setRetryPolicy(retryPolicy);
  
          return retryTemplate;
      }
  </code></pre>
  
  <p>I expect that retrier will retry only after IOException but it retry after all exceptions.</p>