lhotari commented on PR #25101:
URL: https://github.com/apache/pulsar/pull/25101#issuecomment-3685840545

   The BadVersionExceptions seem to be another test flakiness problem in 
ManagedCursorTest due to async ledger rollovers. 
   One possible solution is something like this:
   
   ```
       public <T> T retry(ThrowingSupplier<T> supplier) {
           for (int i = 0; i < 10; i++) {
               if (i > 0) {
                   try {
                       log.info("Retrying after 100ms {}/{}", i, 10);
                       Thread.sleep(100);
                   } catch (InterruptedException e) {
                       Thread.currentThread().interrupt();
                   }
               }
               try {
                   return supplier.get();
               } catch (Exception e) {
                   log.warn("Failed to execute supplier: {}", supplier, e);
               }
           }
           throw new RuntimeException("Failed to execute supplier after 10 
retries");
       }
   
       @FunctionalInterface
       public interface ThrowingSupplier<T> {
           T get() throws Exception;
       }
   ```
   This could be added to `BrokerTestUtil` class.
   
   and then using it in the test classes (for example in 
`testNumberOfEntriesWithReopen` method):
   ```
   ledger = retry(() -> factory2.open("my_test_ledger", new 
ManagedLedgerConfig().setMaxEntriesPerLedger(1)));
   ```
   
   
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to