From c4e64310c7080d408249ccd1d32284f69d6e41c5 Mon Sep 17 00:00:00 2001 From: strangelookingnerd <49242855+strangelookingnerd@users.noreply.github.com> Date: Wed, 20 Nov 2024 11:45:05 +0100 Subject: [PATCH] Handle different disruptor versions --- .../AsyncWaitStrategyFactoryConfigTest.java | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncWaitStrategyFactoryConfigTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncWaitStrategyFactoryConfigTest.java index 11072a2e8ba..42cdcb3071c 100644 --- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncWaitStrategyFactoryConfigTest.java +++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncWaitStrategyFactoryConfigTest.java @@ -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; @@ -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 {