Smack/smack-core/src/main/java/org/jivesoftware/smack
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
..
altconnections Position parser at START_ELEMENT before parsing 2020-08-07 15:01:53 +05:30
bind2 Introduce Smack's Modular Connection Architecture 2020-04-04 13:03:31 +02:00
c2s Merge pull request #416 from Flowdalic/connected-boolean 2020-08-07 12:43:53 +02:00
compress Add XMPP.(get|has)Feature(Class|QName) and deprecate (String, String) 2020-07-23 14:32:14 +02:00
compression Add XMPP.(get|has)Feature(Class|QName) and deprecate (String, String) 2020-07-23 14:32:14 +02:00
datatypes Fix datatype.Scalar equals() and hashCode() methods 2019-10-17 12:24:30 +02:00
debugger [core] Deprecate AbstractConnectionListener 2020-05-13 22:14:43 +02:00
filter [core] Add StanzaFilter.asPredicate(Class) 2020-05-18 09:15:14 +02:00
fsm [core] Add String-based StateDescriptor precedence/inferiority declaration methods 2020-07-25 14:27:45 +02:00
initializer Introduce CloseableUtil 2018-08-15 17:25:22 +02:00
internal [core] Rework TLS logic 2020-05-25 15:41:57 +02:00
iqrequest Use QName instead of XmppStringUtils.generateKey() 2019-06-11 12:47:39 +02:00
isr Introduce Smack's Modular Connection Architecture 2020-04-04 13:03:31 +02:00
packet Introduce and use XmlStringBuilder.text() 2020-09-17 14:20:11 +02:00
parsing Re-work data form API 2020-05-13 20:14:41 +02:00
provider [core] Add ProviderManager.getExtensionProvider(QName) 2020-08-28 09:37:29 +02:00
proxy proxy: modernize code by using (ByteArrayOutput|DataInput)Stream 2020-02-23 19:12:54 +01:00
sasl [sasl] Rename getChannelBindingName() to getGs2CbindFlag() 2020-07-02 13:07:17 +02:00
util [tcp] Do not send SM ack after we send a </stream:stream> 2020-09-18 14:36:26 +02:00
AbstractConnectionClosedListener.java [core] Deprecate AbstractConnectionListener 2020-05-13 22:14:43 +02:00
AbstractConnectionListener.java [core] Deprecate AbstractConnectionListener 2020-05-13 22:14:43 +02:00
AbstractXMPPConnection.java Set 'connected' to 'true' as early as possible 2020-08-06 16:32:26 +02:00
AsyncButOrdered.java core: improve AsyncButOrdered 2019-11-08 10:14:21 +01:00
ConnectionConfiguration.java [core] Rework TLS logic 2020-05-25 15:41:57 +02:00
ConnectionCreationListener.java Enable trailing whitespace checkstyle check 2018-05-09 23:26:39 +02:00
ConnectionListener.java Add callback method for when Smack is connecting 2020-07-18 12:50:08 +02:00
ExceptionCallback.java Merge branch '4.2' into master-paul-merged 2017-12-17 11:16:02 +01:00
Manager.java [core] Introduce ScheduledAction.Kind for blocking and non-blocking actions 2020-05-18 09:15:14 +02:00
MessageListener.java Enable javadoc checkstyle 2015-03-29 12:29:32 +02:00
NonzaCallback.java Move SASL logic into AbstractXMPPConnection 2019-09-25 13:49:21 +02:00
PacketListener.java Enable javadoc checkstyle 2015-03-29 12:29:32 +02:00
PresenceListener.java Enable javadoc checkstyle 2015-03-29 12:29:32 +02:00
ReconnectionListener.java Fix minor codestyle issues 2017-12-17 11:03:46 +01:00
ReconnectionManager.java [core] Deprecate AbstractConnectionListener 2020-05-13 22:14:43 +02:00
SASLAuthentication.java Add XMPP.(get|has)Feature(Class|QName) and deprecate (String, String) 2020-07-23 14:32:14 +02:00
ScheduledAction.java [core] Introduce ScheduledAction.Kind for blocking and non-blocking actions 2020-05-18 09:15:14 +02:00
SmackConfiguration.java Remove deprecated methods/fields scheduled for removal in Smack 4.4 2020-04-04 13:03:48 +02:00
SmackException.java NoEndpointDiscoveredException: s/Not/No 2020-07-28 19:00:04 +02:00
SmackFuture.java Introduce Smack's Modular Connection Architecture 2020-04-04 13:03:31 +02:00
SmackInitialization.java core: use addCompressionHandler() instead directly adding to the list 2020-04-09 15:14:09 +02:00
SmackReactor.java [core] Do not weakly reference "channel selected" callback 2020-05-30 19:45:59 +02:00
StanzaCollector.java Enable werror for javadoc and fix javadoc issues 2019-08-30 12:08:30 +02:00
StanzaListener.java Enable werror for javadoc and fix javadoc issues 2019-08-30 12:08:30 +02:00
UnparseableStanza.java Enable trailing whitespace checkstyle check 2018-05-09 23:26:39 +02:00
XMPPConnection.java Add XMPP.(get|has)Feature(Class|QName) and deprecate (String, String) 2020-07-23 14:32:14 +02:00
XMPPConnectionRegistry.java Enable trailing whitespace checkstyle check 2018-05-09 23:26:39 +02:00
XMPPException.java Enable werror for javadoc and fix javadoc issues 2019-08-30 12:08:30 +02:00
XmppInputOutputFilter.java Remove SynchronizationPoint 2020-05-31 19:48:47 +02:00
package-info.java Add JavadocPackage checkstyle 2015-04-04 17:16:47 +02:00