AnsweredAssumed Answered

Chat state causing PacketParserUtils.parseMessage to throw IllegalStateException in Smack 4.2.0-rc2

Question asked by Luca on Jan 22, 2017
Latest reply on Jan 25, 2017 by Anno van Vliet

With Smack 4.2.0-rc2, when PacketParserUtils.parseMessage receives a packet with a chatestate such as :

 

<message from='test1@test.chat/My-Mac-Pro'

  xmlns='jabber:client' xml:lang='en' type='chat' to='test2@test.chat' id='aacba'>

  <body>Test</body>

  <active

  xmlns='http://jabber.org/protocol/chatstates'/>

  </message>


A IllegalStateException("Invalid Stanza: Must not contain text or mixed content as direct child of <message/>") is thrown here:

 

public static Message parseMessage(XmlPullParser parser){

...

int eventType = parser.next();

   switch (eventType) {

   case XmlPullParser.START_TAG:

  String elementName = parser.getName();

  String namespace = parser.getNamespace();

   switch(elementName) {

   ....

   case XmlPullParser.TEXT:

   throw new IllegalStateException("Invalid Stanza: Must not contain text or mixed content as direct child of <message/>");

  }

}

}

 

Am I missing something in smack 4.2 to be able to handle messages with chat state? Or is this a bug?

Outcomes