Stream Management can't handle unexpected input

Current stream management code does not handle unexpected input well. I have a server that is returning the message id as the “h” attribute on stream management ack requests, which results in the exception below and a complete shutdown of the XMPPConnection.

11-06 14:13:37.147 W/AbstractXMPPConnection﹕ Connection closed with error

java.lang.NumberFormatException: Invalid long: “w49kv-15”

at java.lang.Long.invalidLong(Long.java:124)

at java.lang.Long.parse(Long.java:361)

at java.lang.Long.parseLong(Long.java:352)

at java.lang.Long.parseLong(Long.java:318)

at java.lang.Long.valueOf(Long.java:476)

at org.jivesoftware.smack.util.ParserUtils.getLongAttribute(ParserUtils.java:98)

at org.jivesoftware.smack.tcp.sm.provider.ParseStreamManagement.ackAnswer(ParseStr eamManagement.java:82)

at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPC onnection.java:1187)

at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$200(XMPPTCPCon nection.java:970)

at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnecti on.java:989)

Seems like just ignoring the ack when encountering a parse failure would be better.

Incidentally, I don’t think shutting down the XMPPConnection on an unexpected exception is desirable behavior either, but that’s probably a discussion for another thread.

Seems like just ignoring the ack when encountering a parse failure would be better.
Ignoring errors is usually not a good idea, especially when it comes to parsing of non-stanza elements.

May I ask which server implementation thinks it’s a good idea to use a specified attribute in a completely different way, with a different value type?

Incidentally, I don’t think shutting down the XMPPConnection on an unexpected exception is desirable behavior either, but that’s probably a discussion for another thread.

Smack has parsing exceptions callbacks, but those are only for stanzas. Same as above: Ignoring parsing errors is usually not a good idea.