Smack/smack-core/src/main/java/org/jivesoftware/smack/util
Florian Schmaus 525ee09ea1 [tcp] Do not send SM ack after we send a </stream:stream>
Do net put an ack to the queue if it has already been shutdown. Some
servers, like ejabberd, like to request an ack even after we have send
a stream close (and hance the queue was shutdown). If we would not
check here, then the ack would dangle around in the queue, and be send
on the next re-connection attempt even before the stream open.

See the following trace of the MUC bookmarks integration test. The
fact that it is a MUC test does not matter, but this test does
disconnect the connection and reconnect it. Not how the server,
ejabberd in this case, requests an SM ack by sending an <r/> even
though we already send the </stream:stream>:

22:22:05 SENT (4):
<iq id='MD4UC-61' type='set'>
  <query xmlns='jabber:iq:private'>
    <storage xmlns='storage:bookmarks'>
      <conference name='Smack Inttest: 7in7j' autojoin='true' jid='y9jcn5@conference.salem.geekplace.eu'>
        <nick>
          Nick-P2VXD7
        </nick>
      </conference>
    </storage>
  </query>
</iq>
22:22:05 RECV (4):
<r xmlns='urn:xmpp:sm:3'/>
22:22:05 SENT (4):
<a xmlns='urn:xmpp:sm:3' h='29'/>
22:22:05 RECV (4):
<message to='sinttest-7in7j-4@salem.geekplace.eu' from='sinttest-7in7j-4@salem.geekplace.eu' type='headline'>
  <event xmlns='http://jabber.org/protocol/pubsub#event'>
    <items node='storage:bookmarks'>
      <item id='current'>
        <storage xmlns='storage:bookmarks'>
          <conference name='Smack Inttest: 7in7j' autojoin='true' jid='y9jcn5@conference.salem.geekplace.eu'>
            <nick>
              Nick-P2VXD7
            </nick>
          </conference>
        </storage>
      </item>
    </items>
  </event>
  <addresses xmlns='http://jabber.org/protocol/address'>
    <address jid='sinttest-7in7j-4@salem.geekplace.eu/1415073683806426185213090' type='replyto'/>
  </addresses>
</message>
22:22:05 RECV (4):
<iq xml:lang='en-US' to='sinttest-7in7j-4@salem.geekplace.eu/1415073683806426185213090' from='sinttest-7in7j-4@salem.geekplace.eu' type='result' id='MD4UC-61'/>
22:22:05 SENT (4):
<presence id='6MS6J-20' type='unavailable'/>
<a xmlns='urn:xmpp:sm:3' h='31'/>
<!-- We have closed the stream -->
</stream:stream>
<!-- But the server still requests an SM ack -->
22:22:05 RECV (4):
<r xmlns='urn:xmpp:sm:3'/>
22:22:05 RECV (4):
</stream:stream>
22:22:05 XMPPConnection closed (XMPPTCPConnection[sinttest-7in7j-4@salem.geekplace.eu/1415073683806426185213090] (4))
22:22:05 SENT (4):
<a xmlns='urn:xmpp:sm:3' h='31'/>
22:22:05 SENT (4):
<stream:stream xmlns='jabber:client' to='salem.geekplace.eu' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' from='sinttest-7in7j-4@salem.geekplace.eu' xml:lang='en-US'>
22:22:05 RECV (4): ?xml version='1.0'?>
<stream:stream id='3379123514446782311' ver
22:22:05 RECV (4): sion='1.0' xml:lang='en' xmlns:stream='http://etherx.jabber.org/streams' xmlns='jabber:client'>
<stream:error>
  <invalid-xml xmlns='urn:ietf:params:xml:ns:xmpp-streams'/>
</stream:error>
</stream:stream>
22:22:05 XMPPConnection closed due to an exception (XMPPTCPConnection[sinttest-7in7j-4@salem.geekplace.eu/1415073683806426185213090] (4))
org.jivesoftware.smack.XMPPException$StreamErrorException: invalid-xml You can read more about the meaning of this stream error at http://xmpp.org/rfcs/rfc6120.html#streams-error-conditions
<stream:error><invalid-xml xmlns='urn:ietf:params:xml:ns:xmpp-streams'/></stream:error>
	at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:981)
	at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$700(XMPPTCPConnection.java:913)
	at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:936)
	at java.base/java.lang.Thread.run(Thread.java:834)
2020-09-18 14:36:26 +02:00
..
dns Introduce Smack's Modular Connection Architecture 2020-04-04 13:03:31 +02:00
rce Introduce Smack's Modular Connection Architecture 2020-04-04 13:03:31 +02:00
stringencoder Correct ALPHABET in `BASE32.java` 2020-01-28 20:19:42 +05:30
ArrayBlockingQueueWithShutdown.java [tcp] Do not send SM ack after we send a </stream:stream> 2020-09-18 14:36:26 +02:00
Async.java Enable werror for javadoc and fix javadoc issues 2019-08-30 12:08:30 +02:00
BooleansUtils.java Improve message of StressTestFailedException.NotAllMessagesReceivedException 2019-02-17 21:47:16 +01:00
ByteUtils.java Enable werror for javadoc and fix javadoc issues 2019-08-30 12:08:30 +02:00
CallbackRecipient.java Add "whitespace after comma" checkstyle rule 2019-05-17 21:56:46 +02:00
CleaningWeakReferenceMap.java fix: Cleans the multiUserChats map. 2018-05-21 14:54:23 -05:00
CloseableUtil.java Add CloseableUtil.maybeClose(Closeable) 2019-05-18 13:25:31 +02:00
CollectionUtil.java Re-work data form API 2020-05-13 20:14:41 +02:00
Consumer.java Add util.Consumer and use it in StateDescriptorGraph 2019-09-23 16:12:48 +02:00
DNSUtil.java Introduce Smack's Modular Connection Architecture 2020-04-04 13:03:31 +02:00
EqualsUtil.java core: add shortcut via hash in EqualsUtil 2020-04-13 20:40:10 +02:00
EventManger.java Enable werror for javadoc and fix javadoc issues 2019-08-30 12:08:30 +02:00
ExceptionCallback.java Fix minor codestyle issues 2017-12-17 11:19:41 +01:00
ExceptionUtil.java Make ExceptionUtil.getStackTrace(Throwable) null safe 2019-07-04 15:47:46 +02:00
ExtendedAppendable.java Introduce AbstractStats 2020-05-18 09:15:14 +02:00
FileUtils.java s/occured/occurred/ 2019-10-30 12:02:36 +01:00
Function.java Introduce Smack's Modular Connection Architecture 2020-04-04 13:03:31 +02:00
HashCode.java Introduce EqualsUtil and HashCode.(Builder|Cache) 2019-06-12 14:51:17 +02:00
InternetAddress.java Introduce util.InternetAddress 2019-06-03 17:41:10 +02:00
LazyStringBuilder.java LazyStringBuilder: Wrap NPE in RuntimeException 2019-09-18 09:01:04 +02:00
MAC.java Add SCRAM-SHA1 support 2014-10-21 15:03:48 +02:00
MD5.java Don't reinvent methods in HashManager 2017-08-16 14:55:25 +02:00
MultiMap.java Delete TypedCloneable 2020-06-14 17:38:51 +02:00
NumberUtil.java [core] Improve NumberUtil's exception message and fix javadoc 2020-05-24 13:08:03 +02:00
Objects.java Enable werror for javadoc and fix javadoc issues 2019-08-30 12:08:30 +02:00
ObservableReader.java Enable trailing whitespace checkstyle check 2018-05-09 23:26:39 +02:00
ObservableWriter.java Enable trailing whitespace checkstyle check 2018-05-09 23:26:39 +02:00
OutputStreamUtil.java proxy: modernize code by using (ByteArrayOutput|DataInput)Stream 2020-02-23 19:12:54 +01:00
PacketParserUtils.java Position parser at START_ELEMENT before parsing 2020-08-07 15:01:53 +05:30
PacketUtil.java core: remove deprecated methods in PacketUtil 2020-04-13 21:25:28 +02:00
ParserUtils.java Position parser at START_ELEMENT before parsing 2020-08-07 15:01:53 +05:30
Predicate.java Introduce XMPPConnection.add(Message|Presence)Interceptor 2019-10-25 21:41:55 +02:00
RandomUtil.java Add support for XEP-0418: DNS Queries over XMPP (DoX) 2019-04-09 10:56:47 +02:00
ReaderListener.java Enable trailing whitespace checkstyle check 2018-05-09 23:26:39 +02:00
SHA1.java Don't reinvent methods in HashManager 2017-08-16 14:55:25 +02:00
SecurityUtil.java OpenPGP: Bump Pgpainless to 0.0.1-alpha7 2019-07-30 09:37:19 +02:00
SslContextFactory.java [core] Rework TLS logic 2020-05-25 15:41:57 +02:00
StringUtils.java StringUtils: Fix typo and expose unambiguous alphabet as string 2020-07-15 22:15:38 +02:00
SuccessCallback.java Merge branch '4.2' into master-paul-merged 2017-12-17 11:16:02 +01:00
Supplier.java Remove SynchronizationPoint 2020-05-31 19:48:47 +02:00
SystemUtil.java Throw exception if smack-java7 is loaded on Android 2015-04-25 22:53:46 +02:00
TLSUtils.java [core] Rework TLS logic 2020-05-25 15:41:57 +02:00
ToStringUtil.java Introduce StanzaBuilder 2019-10-25 21:41:55 +02:00
UTF8.java SmackReactor/NIO, Java8/Android19, Pretty print XML, FSM connections 2019-02-05 13:18:03 +01:00
WriterListener.java Enable trailing whitespace checkstyle check 2018-05-09 23:26:39 +02:00
XmlStringBuilder.java Introduce and use XmlStringBuilder.text() 2020-09-17 14:20:11 +02:00
XmlUtil.java Catch IllegalArgumentException in XmlUtil clinit 2018-10-14 12:10:50 +02:00
XmppElementUtil.java [core] Add XmppElementUtil.castOrThrow(ExtensionElement, Class) 2020-08-29 16:29:22 +02:00
package-info.java Add JavadocPackage checkstyle 2015-04-04 17:16:47 +02:00