Skip to content

Possible NullPointerException #6

@spike-commander

Description

@spike-commander

Possible NullPointerException (Most serious bug) in the file Chat activity.Java

In:

void sendMessageToUser(String message){
    chatroomModel.setLastMessageTimestamp(Timestamp.now());

chatroomModel might be null because:

getOrCreateChatroomModel() runs asynchronously

User may click send before Firebase finishes loading

Fix

Add a null check:

if(chatroomModel == null){
    Log.e("ChatActivity","Chatroom not initialized yet");
    return;
}

OR disable send button until chatroom loads.

Hope this small contribution may help in creating an amazing application 🤩
Thanku

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions