Quantcast
Channel: Ignite Realtime : Unanswered Discussions - Support
Viewing all articles
Browse latest Browse all 4979

NullPointerException thrown when trying to sendMessage from ChatManager

$
0
0

Hi,

 

I'm getting NullPointerException randomly (not always reproducible) when trying to send a Chat message.

Method is sendMessage and it's happening when it tries to make connection().sendPacket(message).

Looking at the code I've seen connection returns a weakReference and it is null when trying to get it. Maybe there is a need of adding a null check for connection on the following method?

void sendMessage(Chat chat, Message message) throws NotConnectedException {   
      
for(Map.Entry<MessageListener, PacketFilter> interceptor : interceptors.entrySet()) {    
               PacketFilter filter = interceptor.getValue();
       
               if(filter != null && filter.accept(message)) {
          
            interceptor.getKey().processMessage(message);        
               }
   
       }
   
// Ensure that messages being sent have a proper FROM value    
     if (message.getFrom() == null) {        
               message.setFrom(connection().getUser());
   
     }
   
     connection().sendPacket(message);
}

 

Could you please take a look?

 

The library version is: 4.1.0-beta1 (4.0.6-416-gfd69a4c 2015-01-14)

 

Thanks in advance!


Viewing all articles
Browse latest Browse all 4979

Trending Articles