Skip to content

Commit

Permalink
Handle different disruptor versions
Browse files Browse the repository at this point in the history
  • Loading branch information
strangelookingnerd committed Nov 22, 2024
1 parent 414419f commit c4e6431
Showing 1 changed file with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package org.apache.logging.log4j.core.async;

import static org.assertj.core.api.Assertions.fail;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
Expand Down Expand Up @@ -78,11 +79,25 @@ void testIncorrectWaitStrategyFallsBackToDefault(
(AsyncLoggerConfig) ((org.apache.logging.log4j.core.Logger) logger).get();
final AsyncLoggerConfigDisruptor delegate =
(AsyncLoggerConfigDisruptor) loggerConfig.getAsyncLoggerConfigDelegate();
assertEquals(
TimeoutBlockingWaitStrategy.class, delegate.getWaitStrategy().getClass());
assertThat(
"waitstrategy is TimeoutBlockingWaitStrategy",
delegate.getWaitStrategy() instanceof TimeoutBlockingWaitStrategy);

if (DisruptorUtil.DISRUPTOR_MAJOR_VERSION == 3) {
assertEquals(
org.apache.logging.log4j.core.async.TimeoutBlockingWaitStrategy.class,
delegate.getWaitStrategy().getClass());
assertThat(
"waitstrategy is TimeoutBlockingWaitStrategy",
delegate.getWaitStrategy()
instanceof org.apache.logging.log4j.core.async.TimeoutBlockingWaitStrategy);
} else if (DisruptorUtil.DISRUPTOR_MAJOR_VERSION == 4) {
assertEquals(
com.lmax.disruptor.TimeoutBlockingWaitStrategy.class,
delegate.getWaitStrategy().getClass());
assertThat(
"waitstrategy is TimeoutBlockingWaitStrategy",
delegate.getWaitStrategy() instanceof com.lmax.disruptor.TimeoutBlockingWaitStrategy);
} else {
fail("Unhandled Disruptor version " + DisruptorUtil.DISRUPTOR_MAJOR_VERSION);
}
}

public static class YieldingWaitStrategyFactory implements AsyncWaitStrategyFactory {
Expand Down

0 comments on commit c4e6431

Please sign in to comment.