From 46e30f50d9af97034951091bdfe2bd0911da2fda Mon Sep 17 00:00:00 2001 From: Guus der Kinderen Date: Tue, 10 Nov 2026 17:35:20 +0100 Subject: [PATCH 1/2] OF-3420: Keep Stream Management state consistent between the threads that use a session A stanza that was sent while its session closed could be tracked after the session had already handled its unacknowledged stanzas and disabled Stream Management. StreamManager#sentStanza checked whether Stream Management was enabled before it took the lock under which onClose disables it, so such a stanza was kept, but never routed again or answered with an error. Client sessions hold that lock while they deliver a stanza, which avoided this; other callers of the public method did not. The check is now repeated under the lock, so that the method no longer depends on its caller holding that lock. The status of a session, the time of its last activity, and whether it can be resumed are read by threads other than the one that changes them: those that deliver stanzas to the session, the connection that resumes it, which refuses to resume a session that is closed (OF-2811) or that can no longer be resumed, the listener that handles the closing of its connection, and the task that cleans up detached sessions. Nothing made changes to them visible to those threads, so a session that was closed properly could still be resumed, and the time of the last activity, a long, could be read half-written. All three are now volatile. The thread that delivers a stanza to a client can still find Stream Management not yet enabled, and deliver the stanza without tracking it after the client receives , as that check is made without the lock to reduce lock contention (OF-2921). That remains unchanged, as does the namespace that records whether Stream Management is enabled, which is read without the lock in the same places. --- .../openfire/session/LocalSession.java | 10 ++- .../streammanagement/StreamManager.java | 13 +++- .../streammanagement/StreamManagerTest.java | 74 +++++++++++++++++++ 3 files changed, 94 insertions(+), 3 deletions(-) diff --git a/xmppserver/src/main/java/org/jivesoftware/openfire/session/LocalSession.java b/xmppserver/src/main/java/org/jivesoftware/openfire/session/LocalSession.java index e1a35d2fe6..f60d5ca438 100644 --- a/xmppserver/src/main/java/org/jivesoftware/openfire/session/LocalSession.java +++ b/xmppserver/src/main/java/org/jivesoftware/openfire/session/LocalSession.java @@ -72,8 +72,11 @@ public abstract class LocalSession implements Session { /** * The current session status. + * + * It is read without a lock by threads other than the one that changes it, such as those that deliver stanzas to + * the session, and the thread of a connection that resumes the session. */ - protected Status status = Status.CONNECTED; + protected volatile Status status = Status.CONNECTED; /** * The connection that this session represents. @@ -89,7 +92,10 @@ public abstract class LocalSession implements Session { protected final long startDate = System.currentTimeMillis(); - private long lastActiveDate; + /** + * The time of the last activity of the session. It is read by the task that cleans up detached sessions. + */ + private volatile long lastActiveDate; private AtomicLong clientPacketCount = new AtomicLong( 0 ); diff --git a/xmppserver/src/main/java/org/jivesoftware/openfire/streammanagement/StreamManager.java b/xmppserver/src/main/java/org/jivesoftware/openfire/streammanagement/StreamManager.java index 1e20c260c8..334bf85af8 100644 --- a/xmppserver/src/main/java/org/jivesoftware/openfire/streammanagement/StreamManager.java +++ b/xmppserver/src/main/java/org/jivesoftware/openfire/streammanagement/StreamManager.java @@ -76,7 +76,12 @@ public class StreamManager { .build(); private final Logger Log; - private boolean resume = false; + + /** + * Whether the session can be resumed. It is read without a lock by threads other than the one that changes it, such + * as the thread of a connection that resumes the session, and the listener that handles the closing of a connection. + */ + private volatile boolean resume = false; public static class UnackedPacket { public final long x; @@ -769,6 +774,12 @@ public void sentStanza(Packet packet) { synchronized (this) { + if ( !isEnabled() ) { + // OF-3420: Stream Management was disabled after the check above, for example by onClose(), which handled the unacknowledged stanzas already. + // A stanza that is tracked after that would never be handled. + Log.trace( "Not tracking stanza of type '{}' with ID '{}', as Stream Management was disabled while it was sent. Session: {}", packet.getElement().getName(), packet.getID(), session ); + return; + } final Connection connection = session.getConnection(); if ( exceededMaximumUnacknowledgedStanzas && packet instanceof Message && connection != null && connection.isClosed() && connection.getPacketDeliverer() != null ) { // OF-3434: The fallback of the closed connection stores this message offline. Tracking it as well would deliver it twice. diff --git a/xmppserver/src/test/java/org/jivesoftware/openfire/streammanagement/StreamManagerTest.java b/xmppserver/src/test/java/org/jivesoftware/openfire/streammanagement/StreamManagerTest.java index 1b1ee21306..d213855ad3 100644 --- a/xmppserver/src/test/java/org/jivesoftware/openfire/streammanagement/StreamManagerTest.java +++ b/xmppserver/src/test/java/org/jivesoftware/openfire/streammanagement/StreamManagerTest.java @@ -48,7 +48,11 @@ import org.xmpp.packet.StreamError; import java.lang.reflect.Field; +import java.lang.management.ManagementFactory; +import java.lang.management.ThreadInfo; +import java.lang.management.ThreadMXBean; import java.math.BigInteger; +import java.util.Collection; import java.util.List; import java.util.Locale; import java.util.concurrent.CompletableFuture; @@ -57,6 +61,7 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicLong; +import java.util.concurrent.atomic.AtomicReference; import static org.junit.jupiter.api.Assertions.*; import static org.mockito.Mockito.*; @@ -1757,4 +1762,73 @@ private static void setCounter(final StreamManager sm, final String fieldName, f field.setAccessible(true); ((AtomicLong) field.get(sm)).set(value); } + + /** + * Verifies that a stanza that is sent while the session closes is not tracked once the stanzas that the peer did + * not acknowledge were handled, and Stream Management was disabled (OF-3420). Such a stanza would never be handled. + * + * The thread that sends the stanza finds Stream Management enabled, and then waits for the lock of the stream + * manager, which this test holds while the session closes. + */ + @Test + void stanzaSentWhileSessionClosesIsNotTrackedAfterUnacknowledgedStanzasWereHandled() throws Exception + { + // Setup test fixture. + final LocalClientSession session = authenticatedClientSession(); + final StreamManager sm = enabledStreamManager(session, StreamManager.NAMESPACE_V3); + final PacketRouter router = mock(PacketRouter.class); + final AtomicReference failure = new AtomicReference<>(); + final Thread sender = new Thread(() -> { + try { + sm.sentStanza(message("sent-while-closing")); + } catch (final Throwable t) { + failure.set(t); + } + }, "OF-3420-sender"); + + // Execute system under test. + synchronized (sm) { + sender.start(); + awaitBlockedOn(sender, sm); + sm.onClose(router, SERVER_ADDRESS); + } + sender.join(TimeUnit.SECONDS.toMillis(10)); + + // Verify result. + assertFalse(sender.isAlive(), "The thread that sends the stanza must finish once the lock is released."); + assertNull(failure.get(), "Sending the stanza must not fail, but it threw: " + failure.get()); + assertEquals(0, unacknowledgedStanzaCount(sm), "A stanza that is sent after the unacknowledged stanzas of the session were handled must not be tracked, as it would never be handled."); + } + + /** + * Returns the number of stanzas that the stream manager tracks as unacknowledged. It is read from its private queue, + * as a stream manager that was closed offers no other way to observe them. + */ + private static int unacknowledgedStanzaCount(final StreamManager sm) throws Exception + { + final Field field = StreamManager.class.getDeclaredField("unacknowledgedServerStanzas"); + field.setAccessible(true); + synchronized (sm) { + return ((Collection) field.get(sm)).size(); + } + } + + /** + * Waits until a thread waits to obtain the lock of an object, failing when it ends before that, or does not wait + * within ten seconds. + */ + private static void awaitBlockedOn(final Thread thread, final Object monitor) + { + final ThreadMXBean threads = ManagementFactory.getThreadMXBean(); + final long deadline = System.nanoTime() + TimeUnit.SECONDS.toNanos(10); + while (true) { + final ThreadInfo info = threads.getThreadInfo(thread.getId()); + if (info != null && info.getThreadState() == Thread.State.BLOCKED && info.getLockInfo() != null && info.getLockInfo().getIdentityHashCode() == System.identityHashCode(monitor)) { + return; + } + assertTrue(thread.isAlive(), "Test fixture expects the thread to wait for the lock, but it ended."); + assertTrue(System.nanoTime() < deadline, "Test fixture expects the thread to wait for the lock within ten seconds."); + Thread.onSpinWait(); + } + } } From 6e5c6b8b9360d528050a3479aab287db1d10229b Mon Sep 17 00:00:00 2001 From: Guus der Kinderen Date: Tue, 10 Nov 2026 17:42:43 +0100 Subject: [PATCH 2/2] OF-3420: Allow the sets that sessions share between threads to be read while they change The termination delegates of a stream manager, which decide whether a detached session can be ended, are added and removed by any thread, and copied by the task that cleans up detached sessions. The domains that were validated for a server that connected to Openfire are added by the thread that processes its data, and read by other threads, such as the one that closes the session and removes the routes of those domains. Both were kept in a HashSet. A change while another thread read the set could make that thread fail with a ConcurrentModificationException, or miss an entry. The cleanup task then skipped the session until its next run, and a session that closed could keep the routes of its domains. Both sets can now be read while they change. The copy of the termination delegates reflects them at a single moment, so that a delegate that is replaced while the copy is made, by adding its replacement before removing it, is not missed together with its replacement. The cleanup task would otherwise decide without either of them, and could end a session that both would keep. A termination delegate or validated domain of null, which the methods do not accept, now causes a NullPointerException instead of being added or ignored. --- .../session/LocalIncomingServerSession.java | 10 +- .../streammanagement/StreamManager.java | 14 +- ...mingServerSessionValidatedDomainsTest.java | 98 +++++++++++++ .../streammanagement/StreamManagerTest.java | 133 ++++++++++++++++++ 4 files changed, 248 insertions(+), 7 deletions(-) create mode 100644 xmppserver/src/test/java/org/jivesoftware/openfire/session/LocalIncomingServerSessionValidatedDomainsTest.java diff --git a/xmppserver/src/main/java/org/jivesoftware/openfire/session/LocalIncomingServerSession.java b/xmppserver/src/main/java/org/jivesoftware/openfire/session/LocalIncomingServerSession.java index ee6ec1b2e6..cbd0498e19 100644 --- a/xmppserver/src/main/java/org/jivesoftware/openfire/session/LocalIncomingServerSession.java +++ b/xmppserver/src/main/java/org/jivesoftware/openfire/session/LocalIncomingServerSession.java @@ -41,6 +41,7 @@ import java.nio.charset.StandardCharsets; import java.time.Duration; import java.util.*; +import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; /** @@ -72,8 +73,11 @@ public class LocalIncomingServerSession extends LocalServerSession implements In * List of domains, subdomains and virtual hostnames of the remote server that were * validated with this server. The remote server is allowed to send packets to this * server from any of the validated domains. + * + * Domains are added by the thread that processes data from the remote server, and read by other threads, such as + * the one that closes the session. */ - private Set validatedDomains = new HashSet<>(); + private final Set validatedDomains = ConcurrentHashMap.newKeySet(); /** * Domains or subdomain of this server that was used by the remote server @@ -337,7 +341,7 @@ public Collection getValidatedDomains() { * * @param domain the new validated domain, subdomain or virtual host to add. */ - public void addValidatedDomain(String domain) { + public void addValidatedDomain(@Nonnull final String domain) { if (validatedDomains.add(domain)) { // Set the first validated domain as the address of the session if (validatedDomains.size() < 2) { @@ -357,7 +361,7 @@ public void addValidatedDomain(String domain) { * @param domain the domain, subdomain or virtual host to remove from the list of * validated domains. */ - public void removeValidatedDomain(String domain) { + public void removeValidatedDomain(@Nonnull final String domain) { validatedDomains.remove(domain); // Unregister the validated domain for this server session in SessionManager SessionManager.getInstance().unregisterIncomingServerSession(domain, this); diff --git a/xmppserver/src/main/java/org/jivesoftware/openfire/streammanagement/StreamManager.java b/xmppserver/src/main/java/org/jivesoftware/openfire/streammanagement/StreamManager.java index 334bf85af8..62a73257ec 100644 --- a/xmppserver/src/main/java/org/jivesoftware/openfire/streammanagement/StreamManager.java +++ b/xmppserver/src/main/java/org/jivesoftware/openfire/streammanagement/StreamManager.java @@ -41,6 +41,7 @@ import java.net.UnknownHostException; import java.nio.charset.StandardCharsets; import java.util.*; +import java.util.concurrent.CopyOnWriteArraySet; import java.util.concurrent.atomic.AtomicLong; /** @@ -148,9 +149,11 @@ public static boolean isStreamManagementActive() { private Deque unacknowledgedServerStanzas = new LinkedList<>(); /** - * Delegates that can determine if a detached session can be terminated. + * Delegates that can determine if a detached session can be terminated. They are added and removed by any thread, + * and read by the task that cleans up detached sessions. A copy of this set reflects it at a single moment, so that + * a delegate that is replaced while the copy is made cannot be missed together with its replacement. */ - private final Set terminationDelegates = new HashSet<>(); + private final Set terminationDelegates = new CopyOnWriteArraySet<>(); public StreamManager(LocalSession session) { String address; @@ -1012,6 +1015,9 @@ private int getMaximumUnacknowledgedStanzas() /** * Returns a defensive copy of all delegates that can determine if a detached session can be terminated. * + * The copy holds the delegates that were registered at a single moment. A delegate that is added before another + * delegate is removed is therefore never missing from the copy together with that other delegate. + * * @return all delegates that can determine if a detached session can be terminated. */ public Set getTerminationDelegates() @@ -1030,7 +1036,7 @@ public Set getTerminationDelegates() */ public void addTerminationDelegate(@Nonnull final TerminationDelegate delegate) { - terminationDelegates.add(delegate); + terminationDelegates.add(Objects.requireNonNull(delegate, "Argument 'delegate' cannot be null.")); } /** @@ -1043,7 +1049,7 @@ public void addTerminationDelegate(@Nonnull final TerminationDelegate delegate) */ public void removeTerminationDelegate(@Nonnull final TerminationDelegate delegate) { - terminationDelegates.remove(delegate); + terminationDelegates.remove(Objects.requireNonNull(delegate, "Argument 'delegate' cannot be null.")); } /** diff --git a/xmppserver/src/test/java/org/jivesoftware/openfire/session/LocalIncomingServerSessionValidatedDomainsTest.java b/xmppserver/src/test/java/org/jivesoftware/openfire/session/LocalIncomingServerSessionValidatedDomainsTest.java new file mode 100644 index 0000000000..f2dd3da4a4 --- /dev/null +++ b/xmppserver/src/test/java/org/jivesoftware/openfire/session/LocalIncomingServerSessionValidatedDomainsTest.java @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2026 Ignite Realtime Foundation. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jivesoftware.openfire.session; + +import org.jivesoftware.Fixtures; +import org.jivesoftware.openfire.Connection; +import org.jivesoftware.openfire.XMPPServer; +import org.jivesoftware.openfire.spi.BasicStreamIDFactory; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.withSettings; + +/** + * Verifies that the domains that were validated for a {@link LocalIncomingServerSession} can be read while a domain is + * validated (OF-3420). Domains are validated by the thread that processes data from the remote server, while other + * threads, such as the one that closes the session, read them. + * + * @author Guus der Kinderen, guus@goodbytes.nl + */ +public class LocalIncomingServerSessionValidatedDomainsTest +{ + private static final String REMOTE_DOMAIN = "remote.example.org"; + + private LocalIncomingServerSession session; + + @BeforeAll + public static void setUpClass() throws Exception + { + Fixtures.reconfigureOpenfireHome(); + Fixtures.disableDatabasePersistence(); + } + + @BeforeEach + public void setUp() + { + Fixtures.clearExistingProperties(); + + final XMPPServer xmppServer = Fixtures.mockXMPPServer(); + //noinspection deprecation + XMPPServer.setInstance(xmppServer); + + final Connection connection = mock(Connection.class, withSettings().lenient()); + session = new LocalIncomingServerSession(Fixtures.XMPP_DOMAIN, connection, new BasicStreamIDFactory().createStreamID(), REMOTE_DOMAIN); + } + + @AfterEach + public void tearDown() + { + Fixtures.clearExistingProperties(); + //noinspection deprecation + XMPPServer.setInstance(null); + } + + /** + * Verifies that the validated domains can be iterated while a domain is validated. The domain is validated between + * two steps of the iteration, which stands in for another thread that validates it at that moment. + */ + @Test + public void validatedDomainsCanBeIteratedWhileDomainIsValidated() + { + // Setup test fixture. + session.addValidatedDomain(REMOTE_DOMAIN); + session.addValidatedDomain("other.example.org"); + final Iterator iterator = session.getValidatedDomains().iterator(); + final List iterated = new ArrayList<>(); + iterated.add(iterator.next()); + + // Execute system under test. + session.addValidatedDomain("third.example.org"); + assertDoesNotThrow(() -> iterator.forEachRemaining(iterated::add), "Iterating the validated domains must not fail when a domain is validated at the same time."); + + // Verify result. + assertTrue(iterated.containsAll(List.of(REMOTE_DOMAIN, "other.example.org")), "The domains that were validated before the iteration started must be iterated, but were: " + iterated); + assertTrue(session.isValidDomain("third.example.org"), "The domain that was validated during the iteration must be valid."); + } +} diff --git a/xmppserver/src/test/java/org/jivesoftware/openfire/streammanagement/StreamManagerTest.java b/xmppserver/src/test/java/org/jivesoftware/openfire/streammanagement/StreamManagerTest.java index d213855ad3..ff243b2573 100644 --- a/xmppserver/src/test/java/org/jivesoftware/openfire/streammanagement/StreamManagerTest.java +++ b/xmppserver/src/test/java/org/jivesoftware/openfire/streammanagement/StreamManagerTest.java @@ -48,13 +48,16 @@ import org.xmpp.packet.StreamError; import java.lang.reflect.Field; +import javax.annotation.Nonnull; import java.lang.management.ManagementFactory; import java.lang.management.ThreadInfo; import java.lang.management.ThreadMXBean; import java.math.BigInteger; +import java.time.Duration; import java.util.Collection; import java.util.List; import java.util.Locale; +import java.util.Set; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CountDownLatch; @@ -1800,6 +1803,136 @@ void stanzaSentWhileSessionClosesIsNotTrackedAfterUnacknowledgedStanzasWereHandl assertEquals(0, unacknowledgedStanzaCount(sm), "A stanza that is sent after the unacknowledged stanzas of the session were handled must not be tracked, as it would never be handled."); } + /** + * Verifies that the termination delegates of a session can be obtained while a delegate is added (OF-3420). The + * task that cleans up detached sessions obtains them, while any thread can add or remove one. + * + * Obtaining the delegates computes the hash code of each delegate, while the delegates are iterated. One delegate + * adds another delegate when its hash code is computed, which stands in for a thread that adds a delegate at that + * moment. + */ + @Test + void terminationDelegatesCanBeObtainedWhileDelegateIsAdded() + { + // Setup test fixture. + final StreamManager sm = new StreamManager(authenticatedClientSession()); + final AtomicReference onHashCode = new AtomicReference<>(); + final TerminationDelegate first = new DelegateWithHashCode(1, onHashCode); + final TerminationDelegate second = new DelegateWithHashCode(2, onHashCode); + final TerminationDelegate added = new DelegateWithHashCode(3, onHashCode); + sm.addTerminationDelegate(first); + sm.addTerminationDelegate(second); + onHashCode.set(() -> sm.addTerminationDelegate(added)); + + // Execute system under test. + final Set result = assertDoesNotThrow(sm::getTerminationDelegates, "Obtaining the termination delegates must not fail when a delegate is added at the same time."); + + // Verify result. + assertNull(onHashCode.get(), "Test fixture expects a delegate to be added while the delegates were obtained."); + assertTrue(result.containsAll(Set.of(first, second)), "The delegates that were added before must be obtained, but were: " + result); + assertTrue(sm.getTerminationDelegates().contains(added), "The delegate that was added while the delegates were obtained must be kept."); + } + + /** + * Verifies that a termination delegate that is replaced while the delegates are obtained is not missed together + * with its replacement (OF-3420). The task that cleans up detached sessions would otherwise decide without either + * of them, and could end a session that both would keep. + * + * The replacement is added before the replaced delegate is removed, at the moment that the hash code of the first + * delegate is computed. The hash codes place the replacement before, and the replaced delegate after, the + * delegates that are being iterated. + */ + @Test + void replacedTerminationDelegateIsNotMissedTogetherWithItsReplacement() + { + // Setup test fixture. + final StreamManager sm = new StreamManager(authenticatedClientSession()); + final AtomicReference onHashCode = new AtomicReference<>(); + final TerminationDelegate first = new DelegateWithHashCode(1, onHashCode); + final TerminationDelegate second = new DelegateWithHashCode(2, onHashCode); + final TerminationDelegate replaced = new DelegateWithHashCode(5, onHashCode); + final TerminationDelegate replacement = new DelegateWithHashCode(0, onHashCode); + sm.addTerminationDelegate(first); + sm.addTerminationDelegate(second); + sm.addTerminationDelegate(replaced); + onHashCode.set(() -> { + sm.addTerminationDelegate(replacement); + sm.removeTerminationDelegate(replaced); + }); + + // Execute system under test. + final Set result = assertDoesNotThrow(sm::getTerminationDelegates, "Obtaining the termination delegates must not fail when a delegate is replaced at the same time."); + + // Verify result. + assertNull(onHashCode.get(), "Test fixture expects a delegate to be replaced while the delegates were obtained."); + assertTrue(result.contains(replaced) || result.contains(replacement), "The replaced delegate or its replacement must be obtained, but the delegates were: " + result); + } + + /** + * Verifies that a termination delegate of null is refused, rather than added (OF-3420). + */ + @Test + void addingNullTerminationDelegateIsRefused() + { + // Setup test fixture. + final StreamManager sm = new StreamManager(authenticatedClientSession()); + + // Execute system under test. + assertThrows(NullPointerException.class, () -> sm.addTerminationDelegate(null), "Adding a termination delegate of null must be refused."); + + // Verify result. + assertTrue(sm.getTerminationDelegates().isEmpty(), "No termination delegate must be registered after null was refused, but found: " + sm.getTerminationDelegates()); + } + + /** + * Verifies that removing a termination delegate of null is refused, and leaves the registered delegates in place (OF-3420). + */ + @Test + void removingNullTerminationDelegateIsRefused() + { + // Setup test fixture. + final StreamManager sm = new StreamManager(authenticatedClientSession()); + final TerminationDelegate delegate = allowableInactivity -> false; + sm.addTerminationDelegate(delegate); + + // Execute system under test. + assertThrows(NullPointerException.class, () -> sm.removeTerminationDelegate(null), "Removing a termination delegate of null must be refused."); + + // Verify result. + assertEquals(Set.of(delegate), sm.getTerminationDelegates(), "The registered termination delegate must be kept after removing null was refused."); + } + + /** + * A termination delegate with a fixed hash code, which runs an action, once, when its hash code is computed. + */ + private static final class DelegateWithHashCode implements TerminationDelegate + { + private final int hashCode; + private final AtomicReference onHashCode; + + DelegateWithHashCode(final int hashCode, final AtomicReference onHashCode) + { + this.hashCode = hashCode; + this.onHashCode = onHashCode; + } + + @Override + public boolean shouldTerminate(@Nonnull final Duration allowableInactivity) + { + return false; + } + + @Override + public int hashCode() + { + final Runnable action = onHashCode.getAndSet(null); + if (action != null) { + action.run(); + } + return hashCode; + } + } + /** * Returns the number of stanzas that the stream manager tracks as unacknowledged. It is read from its private queue, * as a stream manager that was closed offers no other way to observe them.