From 5441a2b321013db5b6480ff244e1ee0edb1a61b8 Mon Sep 17 00:00:00 2001 From: Dai Ha Date: Sat, 12 Sep 2026 18:19:43 +0700 Subject: [PATCH] fleetd #567: assert inspect closes probe channel --- .../dev/ltms/fleet/msg/LeadMailboxTest.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/fleetd/src/test/java/dev/ltms/fleet/msg/LeadMailboxTest.java b/fleetd/src/test/java/dev/ltms/fleet/msg/LeadMailboxTest.java index e0c36ae..44ae57c 100644 --- a/fleetd/src/test/java/dev/ltms/fleet/msg/LeadMailboxTest.java +++ b/fleetd/src/test/java/dev/ltms/fleet/msg/LeadMailboxTest.java @@ -19,6 +19,7 @@ import java.util.concurrent.atomic.AtomicLong; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertInstanceOf; +import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -207,6 +208,31 @@ class LeadMailboxTest { } } + /** + * {@link LeadMailbox#inspect} opens a third channel after the mailbox's consume and publish + * channels. Limit this connection to three channels, then require a replacement channel after + * the successful inspect. If inspect leaves its probe open, the broker refuses that replacement. + */ + @Test + void inspectClosesItsSuccessfulProbeChannel() throws Exception { + var factory = LeadMailbox.connectionFactory(uri()); + factory.setRequestedChannelMax(3); + Connection connection = factory.newConnection(); + try (LeadMailbox mailbox = new LeadMailbox(connection, coordId("lead-inspect-probe-close"))) { + LeadChannel.MailboxState state = mailbox.inspect(mailbox.selfCoordId()); + assertTrue(state.exists(), "the owned mailbox must be found before checking the probe channel"); + + Channel replacement = connection.createChannel(); + assertNotNull(replacement, + "inspect must close its successful probe channel; the replacement channel was null"); + try { + assertTrue(replacement.isOpen(), "the replacement channel must be open after inspect returns"); + } finally { + replacement.close(); + } + } + } + /** * fleetd #440: {@code heldDurable()} must be derived from what {@link LeadMailbox#own} actually * did against the real broker — a durable queue declare plus a manual-ack consumer — not a