Skip to content

Possible NullPointerException #6

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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