Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ private void execute() {
private static final Person personInstance = new Person(1, true, "Roman");
private static final Timer timerService = new HashedWheelTimer();

static {
TimerShutdownHook.register(timerService, "tarantool-crud-client-retry-test-timer-shutdown");
}

@BeforeAll
public static void setUp() throws Exception {
if (isCartridgeAvailable()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright (c) 2026 VK DIGITAL TECHNOLOGIES LIMITED LIABILITY COMPANY
* All Rights Reserved.
*/

package io.tarantool.client.integration;

import io.netty.util.Timer;

public final class TimerShutdownHook {
private TimerShutdownHook() {}

public static void register(Timer timer, String name) {
Runtime.getRuntime().addShutdownHook(new Thread(timer::stop, name));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,13 @@ public abstract class BaseTest {
}
};

protected Timer timerService = new HashedWheelTimer();
protected static Timer timerService = new HashedWheelTimer();

protected ConnectionFactory factory = new ConnectionFactory(bootstrap, timerService);
protected static ConnectionFactory factory = new ConnectionFactory(bootstrap, timerService);

static {
TimerShutdownHook.register(timerService, "base-test-timer-shutdown");
}

protected static ArrayValue decodeTuple(IProtoClient client, ArrayValue arrayValue)
throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import io.netty.util.HashedWheelTimer;
import io.netty.util.Timer;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
Expand Down Expand Up @@ -68,6 +69,7 @@
import io.tarantool.core.IProtoClient;
import io.tarantool.core.IProtoClientImpl;
import io.tarantool.core.IProtoFeature;
import io.tarantool.core.connection.ConnectionFactory;
import io.tarantool.core.exceptions.BoxError;
import io.tarantool.core.exceptions.BoxErrorStackItem;
import io.tarantool.core.exceptions.ClientException;
Expand Down Expand Up @@ -1514,17 +1516,23 @@ public void testPing() throws Exception {
}

@Test
public void testTimeoutCancel() throws Exception {
IProtoClient client = createClientAndConnect(address, true);
public void testLocalTimerHasNoPending() throws Exception {
Timer localTimer = new HashedWheelTimer();
IProtoClient client =
new IProtoClientImpl(
new ConnectionFactory(bootstrap, localTimer),
localTimer,
DEFAULT_WATCHER_OPTS,
null,
null,
true);
client.connect(address, 3_000).get();
client.authorize(API_USER, CREDS.get(API_USER)).join();
IProtoMessage message = client.ping().get();
checkMessageHeader(message, IPROTO_OK, 4);
assertEquals(0, message.getBody().map().size());

Set<io.netty.util.Timeout> timers = timerService.stop();
assertTrue(timers.isEmpty());

timerService = new HashedWheelTimer();
assertTrue(localTimer.stop().isEmpty());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright (c) 2026 VK DIGITAL TECHNOLOGIES LIMITED LIABILITY COMPANY
* All Rights Reserved.
*/

package io.tarantool.core.integration;

import io.netty.util.Timer;

public final class TimerShutdownHook {
private TimerShutdownHook() {}

public static void register(Timer timer, String name) {
Runtime.getRuntime().addShutdownHook(new Thread(timer::stop, name));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,8 @@ public abstract class BaseTest {
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 3000);
protected static final Timer timerService = new HashedWheelTimer();
protected static final ConnectionFactory factory = new ConnectionFactory(bootstrap, timerService);

static {
TimerShutdownHook.register(timerService, "jackson-mapping-base-test-timer-shutdown");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright (c) 2026 VK DIGITAL TECHNOLOGIES LIMITED LIABILITY COMPANY
* All Rights Reserved.
*/

package io.tarantool.mapping.integration;

import io.netty.util.Timer;

public final class TimerShutdownHook {
private TimerShutdownHook() {}

public static void register(Timer timer, String name) {
Runtime.getRuntime().addShutdownHook(new Thread(timer::stop, name));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ public class TarantoolSchemaFetcherTest {
private static final Timer timerService = new HashedWheelTimer();
private static final ConnectionFactory factory = new ConnectionFactory(bootstrap, timerService);

static {
TimerShutdownHook.register(timerService, "tarantool-schema-fetcher-test-timer-shutdown");
}

private static TarantoolContainer<?> tt;

private Long spacePersonId;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright (c) 2026 VK DIGITAL TECHNOLOGIES LIMITED LIABILITY COMPANY
* All Rights Reserved.
*/

package io.tarantool.client.integration;

import io.netty.util.Timer;

public final class TimerShutdownHook {
private TimerShutdownHook() {}

public static void register(Timer timer, String name) {
Runtime.getRuntime().addShutdownHook(new Thread(timer::stop, name));
}
}