Skip to content
Merged
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 @@ -4984,6 +4984,11 @@ private void reconcileDeferredHttpTransport(long generation) {
if (configuredMethod == null) configuredMethod = BungeeMethod.PLUGINMESSAGING;
retainHttpForPendingDeliveries(configuredMethod);
stillPending = deferredHttpTransportReconciliation;
// A cancelled transport change may restore the live HTTP configuration
// before the manual reload enters this monitor. Nothing needs replacing,
// and the existing listener must retain ownership of its pending queue.
if (!stillPending && configuredMethod == BungeeMethod.HTTP && httpTransportServer != null
&& !hasChangedLiveHttpConfiguration()) return;
if (!stillPending) httpTransportReconciliationRunning = true;
}
if (stillPending) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2646,6 +2646,37 @@ void deferredHttpTransportChangePollsWhenAckPrecedesQueueRemoval() throws Except
}
}

@Test
void restoringCurrentHttpConfigurationBeforeManualReloadDoesNotReplaceRuntime() throws Exception {
HttpProxyTransportServer transport = Mockito.mock(HttpProxyTransportServer.class);
setProxyField(votingPluginProxy, "httpTransportServer", transport);
var scheduler = Mockito.mock(java.util.concurrent.ScheduledExecutorService.class);
var queued = new java.util.ArrayDeque<Runnable>();
Mockito.doAnswer(call -> {
queued.add(call.getArgument(0));
return Mockito.mock(java.util.concurrent.ScheduledFuture.class);
}).when(scheduler).schedule(Mockito.any(Runnable.class), Mockito.anyLong(), Mockito.any(java.util.concurrent.TimeUnit.class));
votingPluginProxy.setSchedulerForTest(scheduler);
votingPluginProxy.setPendingHttpTransportDeliveries(true);
votingPluginProxy.setMethod(BungeeMethod.HTTP);
Mockito.when(votingPluginProxy.getConfig().getBungeeMethod()).thenReturn("REDIS");
votingPluginProxy.reloadFromControl();
assertEquals(1, queued.size());

// Configuration publication can precede entry into the manual reload.
// Run the old callback in that exact window, without a timing assumption.
Mockito.when(votingPluginProxy.getConfig().getBungeeMethod()).thenReturn("HTTP");
queued.remove().run();
assertEquals(0, votingPluginProxy.getReloadCoreCalls(),
"an unchanged live HTTP listener needs no deferred runtime replacement");
assertEquals(BungeeMethod.HTTP, votingPluginProxy.getMethod());
assertFalse(votingPluginProxy.isRetainingHttpTransportForDeferredReconciliation());
assertTrue(queued.isEmpty(), "a cancelled transport change must not keep polling");
Mockito.verify(transport, Mockito.never()).close();
votingPluginProxy.reloadFromControl();
assertEquals(0, votingPluginProxy.getReloadCoreCalls());
}

@Test
void concurrentManualReloadInvalidatesQueuedDeferredHttpReload() throws Exception {
HttpProxyTransportServer transport = Mockito.mock(HttpProxyTransportServer.class);
Expand Down
Loading