public static void executeWithRetries(
      final Function function,
      final RetryBehaviour retryBehaviour
  ) throws Exception {
    executeWithRetries(() -> {
      function.call();
      return null;
    }, retryBehaviour);
  }
@Test
  public void shouldNotRetryOnCustomRetryableDenied() throws Exception {
    // Given:
    final AtomicBoolean firstCall = new AtomicBoolean(true);
    final Callable<Object> throwsException = () -> {
      if (firstCall.get()) {
        firstCall.set(false);
        // this is a retryable exception usually
        throw new UnknownTopicOrPartitionException("First non-retry exception");
      } else {
        throw new RuntimeException("Test should not retry");
      }
    };

    // When:
    final RuntimeException e = assertThrows(
        UnknownTopicOrPartitionException.class,
        () -> ExecutorUtil.executeWithRetries(throwsException, e2 -> !(e2 instanceof UnknownTopicOrPartitionException))
    );

    // Then:
    assertThat(e.getMessage(), containsString("First non-retry exception"));
  }