Skip to content

Commit

Permalink
Upgrade dependencies; prepare for release
Browse files Browse the repository at this point in the history
* Upgrade Gradle to `8.10.2`
* Upgrade Antora extensions
* Upgrade to the latest `spring-io/antora-ui-spring`
* Upgrade MySQL connector-j to `9.1.0`
* Some code modernization for the `TcpNioConnectionTests`
  • Loading branch information
artembilan committed Oct 23, 2024
1 parent df1a3bc commit eac459a
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 115 deletions.
20 changes: 10 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -89,32 +89,32 @@ ext {
junitJupiterVersion = '5.11.3'
kotlinCoroutinesVersion = '1.8.1'
kryoVersion = '5.6.2'
lettuceVersion = '6.5.0.RC2'
lettuceVersion = '6.4.0.RELEASE'
log4jVersion = '2.24.1'
mailVersion = '2.0.3'
micrometerTracingVersion = '1.4.0-SNAPSHOT'
micrometerVersion = '1.14.0-SNAPSHOT'
micrometerTracingVersion = '1.4.0-RC1'
micrometerVersion = '1.14.0-RC1'
mockitoVersion = '5.14.2'
mongoDriverVersion = '5.2.0'
mysqlVersion = '9.0.0'
mysqlVersion = '9.1.0'
oracleVersion = '23.5.0.24.07'
pahoMqttClientVersion = '1.2.5'
postgresVersion = '42.7.4'
protobufVersion = '4.28.2'
r2dbch2Version = '1.0.0.RELEASE'
reactorVersion = '2024.0.0-SNAPSHOT'
reactorVersion = '2024.0.0-RC1'
resilience4jVersion = '2.2.0'
romeToolsVersion = '2.1.0'
rsocketVersion = '1.1.4'
servletApiVersion = '6.0.0'
smackVersion = '4.4.8'
springAmqpVersion = '3.2.0-SNAPSHOT'
springDataVersion = '2024.1.0-SNAPSHOT'
springAmqpVersion = '3.2.0-RC1'
springDataVersion = '2024.1.0-RC1'
springGraphqlVersion = '1.3.3'
springKafkaVersion = '3.3.0-SNAPSHOT'
springKafkaVersion = '3.3.0-RC1'
springRetryVersion = '2.0.10'
springSecurityVersion = '6.4.0-SNAPSHOT'
springVersion = '6.2.0-SNAPSHOT'
springSecurityVersion = '6.4.0-RC1'
springVersion = '6.2.0-RC2'
springWsVersion = '4.0.11'
testcontainersVersion = '1.20.3'
tomcatVersion = '10.1.31'
Expand Down
6 changes: 3 additions & 3 deletions gradle/docs.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ antora {
]
dependencies = [
'@antora/atlas-extension': '1.0.0-alpha.2',
'@antora/collector-extension': '1.0.0-alpha.3',
'@antora/collector-extension': '1.0.0-beta.3',
'@asciidoctor/tabs': '1.0.0-beta.6',
'@springio/antora-extensions': '1.8.1',
'@springio/asciidoctor-extensions': '1.0.0-alpha.9',
'@springio/antora-extensions': '1.14.2',
'@springio/asciidoctor-extensions': '1.0.0-alpha.14',
]
}

Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionSha256Sum=1541fa36599e12857140465f3c91a97409b4512501c26f9631fb113e392c5bd1
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-bin.zip
distributionSha256Sum=31c55713e40233a8303827ceb42ca48a47267a0ad4bab9177123121e71524c26
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UncheckedIOException;
import java.lang.reflect.Method;
import java.net.ConnectException;
import java.net.InetAddress;
Expand Down Expand Up @@ -76,9 +77,12 @@
import org.springframework.messaging.MessagingException;
import org.springframework.messaging.support.ErrorMessage;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.util.ReflectionUtils;
import org.springframework.util.StopWatch;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.assertj.core.api.Assertions.fail;
import static org.awaitility.Awaitility.await;
import static org.awaitility.Awaitility.with;
Expand Down Expand Up @@ -125,10 +129,10 @@ public void testWriteTimeout(TestInfo testInfo) throws Exception {
s.close();
}
catch (Exception e) {
e.printStackTrace();
ReflectionUtils.rethrowRuntimeException(e);
}
});
assertThat(latch.await(10000, TimeUnit.MILLISECONDS)).isTrue();
assertThat(latch.await(30, TimeUnit.SECONDS)).isTrue();
TcpNioClientConnectionFactory factory =
new TcpNioClientConnectionFactory("localhost", serverSocket.get().getLocalPort());
factory.setLookupHost(true);
Expand Down Expand Up @@ -174,10 +178,10 @@ public void testReadTimeout(TestInfo testInfo) throws Exception {
done.await(10, TimeUnit.SECONDS);
}
catch (Exception e) {
e.printStackTrace();
ReflectionUtils.rethrowRuntimeException(e);
}
});
assertThat(latch.await(10000, TimeUnit.MILLISECONDS)).isTrue();
assertThat(latch.await(30, TimeUnit.SECONDS)).isTrue();
TcpNioClientConnectionFactory factory = new TcpNioClientConnectionFactory("localhost",
serverSocket.get().getLocalPort());
factory.setApplicationEventPublisher(nullPublisher);
Expand Down Expand Up @@ -215,10 +219,10 @@ public void testMemoryLeak(TestInfo testInfo) throws Exception {
readFully(socket.getInputStream(), b);
}
catch (Exception e) {
e.printStackTrace();
ReflectionUtils.rethrowRuntimeException(e);
}
});
assertThat(latch.await(10000, TimeUnit.MILLISECONDS)).isTrue();
assertThat(latch.await(30, TimeUnit.SECONDS)).isTrue();
TcpNioClientConnectionFactory factory = new TcpNioClientConnectionFactory("localhost",
serverSocket.get().getLocalPort());
factory.setApplicationEventPublisher(nullPublisher);
Expand All @@ -231,10 +235,9 @@ public void testMemoryLeak(TestInfo testInfo) throws Exception {
connection.close();
assertThat(!connection.isOpen()).isTrue();
TestUtils.getPropertyValue(factory, "selector", Selector.class).wakeup();
await().atMost(Duration.ofSeconds(10)).until(() -> connections.size() == 0);
await().atMost(Duration.ofSeconds(10)).until(connections::isEmpty);
}
catch (Exception e) {
e.printStackTrace();
fail("Unexpected exception " + e);
}
factory.stop();
Expand Down Expand Up @@ -330,16 +333,12 @@ public void testInsufficientThreads() throws Exception {
}
return null;
});
try {
Object o = future.get(10, TimeUnit.SECONDS);
fail("Expected exception, got " + o);
}
catch (ExecutionException e) {
assertThat(e.getCause().getMessage()).isEqualTo("Timed out waiting for buffer space");
}
finally {
exec.shutdownNow();
}

assertThatExceptionOfType(ExecutionException.class)
.isThrownBy(() -> future.get(10, TimeUnit.SECONDS))
.withStackTraceContaining("Timed out waiting for buffer space");

exec.shutdownNow();
}

@Test
Expand Down Expand Up @@ -374,7 +373,6 @@ public void testSufficientThreads() throws Exception {
}
}
catch (Exception e) {
e.printStackTrace();
throw (Exception) e.getCause();
}
return null;
Expand Down Expand Up @@ -445,18 +443,13 @@ public void testByteArrayReadWithBadArgs() throws Exception {
.getPropertyValue("channelInputStream");
stream.write(ByteBuffer.wrap("foo".getBytes()));
byte[] out = new byte[5];
try {
stream.read(out, 1, 5);
fail("Expected IndexOutOfBoundsException");
}
catch (IndexOutOfBoundsException e) {
}
try {
stream.read(null, 1, 5);
fail("Expected IllegalArgumentException");
}
catch (IllegalArgumentException e) {
}

assertThatExceptionOfType(IndexOutOfBoundsException.class)
.isThrownBy(() -> stream.read(out, 1, 5));

assertThatIllegalArgumentException()
.isThrownBy(() -> stream.read(null, 1, 5));

assertThat(stream.read(out, 0, 0)).isEqualTo(0);
assertThat(stream.read(out)).isEqualTo(3);
}
Expand All @@ -476,7 +469,7 @@ public void testByteArrayBlocksForZeroRead() throws Exception {
stream.read(out);
}
catch (IOException e) {
e.printStackTrace();
throw new UncheckedIOException(e);
}
latch.countDown();
});
Expand Down Expand Up @@ -514,16 +507,12 @@ public Integer answer(InvocationOnMock invocation) {
SocketChannel outChannel = mock(SocketChannel.class);
when(outChannel.socket()).thenReturn(outSocket);
TcpNioConnection outboundConnection = new TcpNioConnection(outChannel, true, false, nullPublisher, null);
doAnswer(new Answer<Object>() {

@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
ByteBuffer buff = invocation.getArgument(0);
byte[] bytes = new byte[buff.limit()];
buff.get(bytes);
written.write(bytes);
return null;
}
doAnswer(invocation -> {
ByteBuffer buff = invocation.getArgument(0);
byte[] bytes = new byte[buff.limit()];
buff.get(bytes);
written.write(bytes);
return null;
}).when(outChannel).write(any(ByteBuffer.class));

MapMessageConverter outConverter = new MapMessageConverter();
Expand All @@ -539,14 +528,10 @@ public Object answer(InvocationOnMock invocation) throws Throwable {

final AtomicReference<Message<?>> inboundMessage = new AtomicReference<Message<?>>();
final CountDownLatch latch = new CountDownLatch(1);
TcpListener listener = new TcpListener() {

@Override
public boolean onMessage(Message<?> message) {
inboundMessage.set(message);
latch.countDown();
return false;
}
TcpListener listener = message1 -> {
inboundMessage.set(message1);
latch.countDown();
return false;
};
inboundConnection.registerListener(listener);
inboundConnection.readPacket();
Expand All @@ -565,19 +550,14 @@ public void testAssemblerUsesSecondaryExecutor() throws Exception {

factory.setSoTimeout(1000);
factory.setTaskExecutor(compositeExec);
final AtomicReference<String> threadName = new AtomicReference<String>();
final AtomicReference<String> threadName = new AtomicReference<>();
final CountDownLatch latch = new CountDownLatch(1);
factory.registerListener(new TcpListener() {

@Override
public boolean onMessage(Message<?> message) {
if (!(message instanceof ErrorMessage)) {
threadName.set(Thread.currentThread().getName());
latch.countDown();
}
return false;
factory.registerListener(message -> {
if (!(message instanceof ErrorMessage)) {
threadName.set(Thread.currentThread().getName());
latch.countDown();
}

return false;
});
factory.start();
TestingUtilities.waitListening(factory, null);
Expand All @@ -598,7 +578,7 @@ public boolean onMessage(Message<?> message) {
socket.getOutputStream().write("foo\r\n".getBytes());
socket.close();

assertThat(latch.await(10, TimeUnit.SECONDS)).isTrue();
assertThat(latch.await(30, TimeUnit.SECONDS)).isTrue();
assertThat(threadName.get()).contains("assembler");

factory.stop();
Expand Down Expand Up @@ -720,17 +700,12 @@ public void publishEvent(Object event) {
});
final CountDownLatch assemblerLatch = new CountDownLatch(1);
final AtomicReference<Thread> assembler = new AtomicReference<Thread>();
factory.registerListener(new TcpListener() {

@Override
public boolean onMessage(Message<?> message) {
if (!(message instanceof ErrorMessage)) {
assembler.set(Thread.currentThread());
assemblerLatch.countDown();
}
return false;
factory.registerListener(message -> {
if (!(message instanceof ErrorMessage)) {
assembler.set(Thread.currentThread());
assemblerLatch.countDown();
}

return false;
});
ThreadPoolTaskExecutor te = new ThreadPoolTaskExecutor();
te.setCorePoolSize(3); // selector, reader, assembler
Expand All @@ -756,38 +731,26 @@ public boolean onMessage(Message<?> message) {

final CountDownLatch readerLatch = new CountDownLatch(4); // 3 dataAvailable, 1 continuing
final CountDownLatch readerFinishedLatch = new CountDownLatch(1);
doAnswer(new Answer<Void>() {

@Override
public Void answer(InvocationOnMock invocation) throws Throwable {
invocation.callRealMethod();
// delay the reader thread resetting writingToPipe
readerLatch.await(10, TimeUnit.SECONDS);
Thread.sleep(100);
readerFinishedLatch.countDown();
return null;
}
doAnswer(invocation -> {
invocation.callRealMethod();
// delay the reader thread resetting writingToPipe
readerLatch.await(10, TimeUnit.SECONDS);
Thread.sleep(100);
readerFinishedLatch.countDown();
return null;
}).when(cis).write(any(ByteBuffer.class));

doReturn(true).when(logger).isTraceEnabled();
doAnswer(new Answer<Void>() {

@Override
public Void answer(InvocationOnMock invocation) throws Throwable {
invocation.callRealMethod();
readerLatch.countDown();
return null;
}
doAnswer(invocation -> {
invocation.callRealMethod();
readerLatch.countDown();
return null;
}).when(logger).trace(contains("checking data avail"));

doAnswer(new Answer<Void>() {

@Override
public Void answer(InvocationOnMock invocation) throws Throwable {
invocation.callRealMethod();
readerLatch.countDown();
return null;
}
doAnswer(invocation -> {
invocation.callRealMethod();
readerLatch.countDown();
return null;
}).when(logger).trace(contains("Nio assembler continuing"));

socket.getOutputStream().write("foo\r\n".getBytes());
Expand Down
2 changes: 1 addition & 1 deletion src/reference/antora/antora-playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ runtime:
format: pretty
ui:
bundle:
url: https://github.com/spring-io/antora-ui-spring/releases/download/v0.4.10/ui-bundle.zip
url: https://github.com/spring-io/antora-ui-spring/releases/download/v0.4.17/ui-bundle.zip

0 comments on commit eac459a

Please sign in to comment.