Buggy code:
protected String deviceId ( String appId , String botUserName ) { } protected DeviceDAO getDeviceDAO ( ) { } protected String deviceName ( String appId , String botUserName ) { } protected static IQ buildAckIQ ( String fromJID , String toJID , String incomingMessageId ) { } public static class AmazingBotProcessor implements AutoResponseProcessor { private static final Logger LOGGER = LoggerFactory . getLogger ( BotRegistrationImpl . AmazingBotProcessor . class ) ; protected AutoRespondingConnection autoRespondingConnection ; @ Override public void initialize ( AutoRespondingConnection connection ) { } public void processIncoming ( Packet packet ) { if ( packet instanceof Message ) { Message message = ( ( Message ) ( packet ) ) ; BotRegistrationImpl . AmazingBotProcessor . LOGGER . debug ( "Sending<seq2seq4repair_space>the<seq2seq4repair_space>amazing<seq2seq4repair_space>message<seq2seq4repair_space>back" ) ; JID fromJID = packet . getFrom ( ) ; JID toJID = packet . getTo ( ) ; packet . setTo ( fromJID ) ; Element mmx = message . getChildElement ( MMX , MMX_NS_MSG_PAYLOAD ) ; Element recieptRequest = message . getChildElement ( XMPP_REQUEST , XMPP_NS_RECEIPTS ) ; boolean receiptRequested = recieptRequest != null ; List < Element > payloadList = mmx . elements ( MMX_PAYLOAD ) ; if ( ( payloadList != null ) || ( ! ( payloadList . isEmpty ( ) ) ) ) { Element payload = payloadList . get ( 0 ) ; payload . setText ( BotRegistrationImpl . AMAZING_MESSAGE ) ; } Element internalMeta = mmx . element ( MMX_MMXMETA ) ; if ( internalMeta != null ) { mmx . remove ( internalMeta ) ; } String userId = JIDUtil . getUserId ( fromJID ) ; String devId = fromJID . getResource ( ) ; String senderId = JIDUtil . getUserId ( toJID ) ; String senderDevId = toJID . getResource ( ) ; MmxHeaders mmxMeta = new MmxHeaders ( ) ; <START_BUG> mmxMeta . put ( TO , new MMXid ( userId , devId , null ) ) ; <END_BUG> mmxMeta . put ( FROM , new MMXid ( senderId , senderDevId , null ) ) ; Element revisedMeta = mmx . addElement ( MMX_MMXMETA ) ; revisedMeta . setText ( GsonData . getGson ( ) . toJson ( mmxMeta ) ) ; Map < String , String > metaMap = new HashMap < String , String > ( ) ; metaMap . put ( TEXT_CONTENT_KEY , BotRegistrationImpl . AMAZING_MESSAGE ) ; Element meta = mmx . element ( MMX_META ) ; if ( meta == null ) { meta = mmx . addElement ( MMX_META ) ; } meta . setText ( GsonData . getGson ( ) . toJson ( metaMap ) ) ; if ( receiptRequested ) { message . deleteExtension ( XMPP_REQUEST , XMPP_NS_RECEIPTS ) ; } try { Thread . sleep ( 1000L ) ; } catch ( InterruptedException e ) { BotRegistrationImpl . AmazingBotProcessor . LOGGER . debug ( "Interrupted<seq2seq4repair_space>exception" , e ) ; } finally { } autoRespondingConnection . sendPacket ( packet ) ; String originalMessageId = packet . getID ( ) ; String from = fromJID . toString ( ) ; String to = toJID . toString ( ) ; BotRegistrationImpl . AmazingBotProcessor . LOGGER . debug ( "Attempting<seq2seq4repair_space>to<seq2seq4repair_space>deliver<seq2seq4repair_space>ack" ) ; IQ ackIQ = BotRegistrationImpl . buildAckIQ ( from , to , originalMessageId ) ; if ( BotRegistrationImpl . AmazingBotProcessor . LOGGER . isDebugEnabled ( ) ) { BotRegistrationImpl . AmazingBotProcessor . LOGGER . debug ( "Ack<seq2seq4repair_space>IQ:{}" , ackIQ . toXML ( ) ) ; } autoRespondingConnection . sendPacket ( ackIQ ) ; if ( receiptRequested ) { BotRegistrationImpl . AmazingBotProcessor . LOGGER . debug ( "Sending<seq2seq4repair_space>delivery<seq2seq4repair_space>receipt<seq2seq4repair_space>for<seq2seq4repair_space>message<seq2seq4repair_space>with<seq2seq4repair_space>id:{}" , originalMessageId ) ; String appId = JIDUtil . getAppId ( to ) ; Message receipt = buildDeliveryReceipt ( appId , from , to , originalMessageId ) ; autoRespondingConnection . sendPacket ( receipt ) ; } } } public void processIncomingRaw ( String rawText ) { } public void terminate ( ) { } protected Message buildDeliveryReceipt ( String appId , String incomingMessageFromJID , String incomingMessageToJID , String incomingMessageId ) { } } public static class EchoBotProcessor extends BotRegistrationImpl . AmazingBotProcessor { private static final Logger LOGGER = LoggerFactory . getLogger ( BotRegistrationImpl . EchoBotProcessor . class ) ; public void processIncoming ( Packet packet ) { if ( packet instanceof Message ) { BotRegistrationImpl . EchoBotProcessor . LOGGER . debug ( "Sending<seq2seq4repair_space>the<seq2seq4repair_space>same<seq2seq4repair_space>message<seq2seq4repair_space>back" ) ; Message message = ( ( Message ) ( packet ) ) ; Element mmx = message . getChildElement ( MMX , MMX_NS_MSG_PAYLOAD ) ; boolean receiptRequested = ( message . getChildElement ( XMPP_REQUEST , XMPP_NS_RECEIPTS ) ) != null ; JID fromJID = message . getFrom ( ) ; JID toJID = message . getTo ( ) ; message . setTo ( fromJID ) ; Element internalMeta = mmx . element ( MMX_MMXMETA ) ; String userId = JIDUtil . getUserId ( fromJID ) ; String devId = fromJID . getResource ( ) ; String mmxMetaJSON = MMXMetaBuilder . build ( userId , devId ) ; if ( internalMeta != null ) { mmx . remove ( internalMeta ) ; } Element revisedMeta = mmx . addElement ( MMX_MMXMETA ) ; revisedMeta . setText ( mmxMetaJSON ) ; if ( receiptRequested ) { message . deleteExtension ( XMPP_REQUEST , XMPP_NS_RECEIPTS ) ; } try { Thread . sleep ( 1000L ) ; } catch ( InterruptedException e ) { e . printStackTrace ( ) ; } finally { } autoRespondingConnection . sendPacket ( message ) ; String originalMessageId = message . getID ( ) ; String from = fromJID . toString ( ) ; String to = toJID . toString ( ) ; BotRegistrationImpl . EchoBotProcessor . LOGGER . debug ( "Attempting<seq2seq4repair_space>to<seq2seq4repair_space>deliver<seq2seq4repair_space>ack" ) ; IQ ackIQ = BotRegistrationImpl . buildAckIQ ( from , to , originalMessageId ) ; if ( BotRegistrationImpl . EchoBotProcessor . LOGGER . isDebugEnabled ( ) ) { BotRegistrationImpl . EchoBotProcessor . LOGGER . debug ( "Ack<seq2seq4repair_space>IQ:{}" , ackIQ . toXML ( ) ) ; } autoRespondingConnection . sendPacket ( ackIQ ) ; if ( receiptRequested ) { BotRegistrationImpl . EchoBotProcessor . LOGGER . debug ( "Sending<seq2seq4repair_space>delivery<seq2seq4repair_space>receipt<seq2seq4repair_space>for<seq2seq4repair_space>message<seq2seq4repair_space>with<seq2seq4repair_space>id:{}" , originalMessageId ) ; String appId = JIDUtil . getAppId ( to ) ; Message receipt = buildDeliveryReceipt ( appId , from , to , originalMessageId ) ; autoRespondingConnection . sendPacket ( receipt ) ; } else { BotRegistrationImpl . EchoBotProcessor . LOGGER . debug ( "Not<seq2seq4repair_space>sending<seq2seq4repair_space>delivery<seq2seq4repair_space>receipt<seq2seq4repair_space>for<seq2seq4repair_space>message<seq2seq4repair_space>with<seq2seq4repair_space>id:{}"

Fix:
mmxMeta . put ( TO , new MMXid [ ] { new MMXid ( userId , devId , null ) } ) ;