From d39941da8fb11bf211756015621ae7a73f03e0cd Mon Sep 17 00:00:00 2001 From: Phil Clay Date: Sat, 27 Jul 2024 11:52:49 -0700 Subject: [PATCH] Upgrade dependencies and maven plugins (#1028) * Upgrade dependencies and maven plugins * Fix flaky test --- pom.xml | 47 ++++++++++--------- .../composite/SequenceJsonProvider.java | 1 + .../LogstashTcpSocketAppenderTest.java | 4 +- .../AccessEventNestedJsonProviderTest.java | 8 +++- .../LoggingEventNestedJsonProviderTest.java | 6 +++ .../logback/util/ThreadLocalHolderTest.java | 6 ++- 6 files changed, 45 insertions(+), 27 deletions(-) diff --git a/pom.xml b/pom.xml index 096c7aed..444202e7 100644 --- a/pom.xml +++ b/pom.xml @@ -23,8 +23,8 @@ UTF-8 - 2.15.2 - 4.2.0 + 2.17.2 + 5.1.0 1.5.6 2.0.2 @@ -32,33 +32,34 @@ 3.4.4 - 3.24.2 - 4.2.0 - 5.9.2 - 5.1.1 + 3.26.3 + 4.2.1 + 5.10.3 + 5.12.0 - 1.6.1 - 4.1 + 3.6.0 + 1.8.0 + 1.6.0 + 4.5 5.1.9 - 3.3.0 - 3.2.0 - 3.11.0 - 3.2.1 - 1.5.0 + 3.4.0 + 3.4.0 + 3.13.0 + 3.5.0 3.0.1 - 3.1.1 - 3.3.0 - 3.5.0 - 2.5.3 + 3.1.2 + 3.4.2 + 3.8.0 + 3.1.1 3.3.1 - 3.4.1 + 3.6.0 3.3.0 - 3.1.0 + 3.3.1 1.6.13 - 1.0.2 + 1.1.0 - 10.7.0 + 10.17.0 true @@ -331,7 +332,7 @@ org.codehaus.mojo flatten-maven-plugin - ${maven-flatten-plugin.version} + ${flatten-maven-plugin.version} ossrh true @@ -735,7 +736,7 @@ org.codehaus.mojo build-helper-maven-plugin - 3.3.0 + ${build-helper-maven-plugin.version} add-sample-sources diff --git a/src/main/java/net/logstash/logback/composite/SequenceJsonProvider.java b/src/main/java/net/logstash/logback/composite/SequenceJsonProvider.java index aca776d0..a9d831b4 100644 --- a/src/main/java/net/logstash/logback/composite/SequenceJsonProvider.java +++ b/src/main/java/net/logstash/logback/composite/SequenceJsonProvider.java @@ -27,6 +27,7 @@ * * @deprecated use {@link net.logstash.logback.composite.loggingevent.SequenceJsonProvider} or {@link net.logstash.logback.composite.accessevent.SequenceJsonProvider} instead. */ +@Deprecated public class SequenceJsonProvider extends AbstractFieldJsonProvider { public static final String FIELD_SEQUENCE = "sequence"; diff --git a/src/test/java/net/logstash/logback/appender/LogstashTcpSocketAppenderTest.java b/src/test/java/net/logstash/logback/appender/LogstashTcpSocketAppenderTest.java index 2877a526..e8015a1e 100644 --- a/src/test/java/net/logstash/logback/appender/LogstashTcpSocketAppenderTest.java +++ b/src/test/java/net/logstash/logback/appender/LogstashTcpSocketAppenderTest.java @@ -117,6 +117,8 @@ protected Future scheduleReaderCallable(Callable readerCallable) { @BeforeEach public void setup() throws Exception { super.setup(); + + appender.setEncoder(encoder); when(socketFactory.createSocket()).thenReturn(socket); when(socket.getOutputStream()).thenReturn(outputStream); @@ -554,7 +556,7 @@ public void eventSent(Appender appender, Socket socket, ILoggingE long e1Tstamp = tstamps.get(e1); long e2Tstamp = tstamps.get(e2); - assertThat(e1Tstamp).isGreaterThan(now + appender.getInitialSendDelay().getMilliseconds()); + assertThat(e1Tstamp).isGreaterThanOrEqualTo(now + appender.getInitialSendDelay().getMilliseconds()); assertThat(e2Tstamp).isGreaterThanOrEqualTo(e1Tstamp); } diff --git a/src/test/java/net/logstash/logback/composite/accessevent/AccessEventNestedJsonProviderTest.java b/src/test/java/net/logstash/logback/composite/accessevent/AccessEventNestedJsonProviderTest.java index a2cdcfc3..c35581e7 100644 --- a/src/test/java/net/logstash/logback/composite/accessevent/AccessEventNestedJsonProviderTest.java +++ b/src/test/java/net/logstash/logback/composite/accessevent/AccessEventNestedJsonProviderTest.java @@ -21,6 +21,7 @@ import ch.qos.logback.access.common.spi.IAccessEvent; import com.fasterxml.jackson.core.JsonGenerator; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InOrder; @@ -42,7 +43,12 @@ public class AccessEventNestedJsonProviderTest { @Mock private AccessEventJsonProviders providers; - + + @BeforeEach + void beforeEach() { + provider.setProviders(providers); + } + @Test public void testWrite() throws IOException { diff --git a/src/test/java/net/logstash/logback/composite/loggingevent/LoggingEventNestedJsonProviderTest.java b/src/test/java/net/logstash/logback/composite/loggingevent/LoggingEventNestedJsonProviderTest.java index bdd19b69..989fca23 100644 --- a/src/test/java/net/logstash/logback/composite/loggingevent/LoggingEventNestedJsonProviderTest.java +++ b/src/test/java/net/logstash/logback/composite/loggingevent/LoggingEventNestedJsonProviderTest.java @@ -24,6 +24,7 @@ import com.fasterxml.jackson.core.JsonFactory; import com.fasterxml.jackson.core.JsonFactoryBuilder; import com.fasterxml.jackson.core.JsonGenerator; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InOrder; @@ -45,6 +46,11 @@ public class LoggingEventNestedJsonProviderTest { @Mock private LoggingEventJsonProviders providers; + + @BeforeEach + void beforeEach() { + provider.setProviders(providers); + } @Test public void testWrite() throws IOException { diff --git a/src/test/java/net/logstash/logback/util/ThreadLocalHolderTest.java b/src/test/java/net/logstash/logback/util/ThreadLocalHolderTest.java index 92891633..012ab623 100644 --- a/src/test/java/net/logstash/logback/util/ThreadLocalHolderTest.java +++ b/src/test/java/net/logstash/logback/util/ThreadLocalHolderTest.java @@ -18,6 +18,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatCode; import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.never; import static org.mockito.Mockito.spy; @@ -249,7 +250,7 @@ public void testFactoryThrowsException() { */ @Test public void testRecycleThrowsException() { - PooledObject obj1 = spy(pool.acquire()); + PooledObject obj1 = pool.acquire(); when(obj1.recycle()).thenThrow(new RuntimeException()); assertThatCode(() -> pool.release()).doesNotThrowAnyException(); @@ -262,7 +263,8 @@ public void testRecycleThrowsException() { */ @Test public void testDisposeThrowsException() { - PooledObject obj1 = spy(pool.acquire()); + PooledObject obj1 = pool.acquire(); + doReturn(false).when(obj1).recycle(); doThrow(new RuntimeException()).when(obj1).dispose(); assertThatCode(() -> pool.release()).doesNotThrowAnyException();