Skip to content

App crashes when comparing Log Objects in RecyclerView Updates #10

@euptron

Description

@euptron

Problem Description

The app encounters a NullPointerException because the equals() method is called on a null Log object during list updates in the RecyclerView. The DiffUtil process, used by AsyncListDiffer for efficient list updates, attempts to compare items but fails if one of the Log objects being compared is null.

Steps to Reproduce the Behavior

  1. Open the app and navigate to the section where logs are displayed in a RecyclerView.
  2. Perform an action that triggers the log update.
  3. The app crashes when the RecyclerView tries to compare log items.

Expected Behavior

  • The app should not crash when updating the RecyclerView. It should ensure that both Log objects being compared are not null before invoking the equals() method.

Crash Details

  • Crash Date: Thu Aug 29 2024 15:28:36 GMT+0100 (West Africa Standard Time)
Crashlytics Issue ID

33308dfde6721aa4e51f9010a1f307ea

  • Thread: main
  • Exception: java.lang.NullPointerException
    Message:
    java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.Object.equals(java.lang.Object)' on a null object reference
    

The crash occurs because the equals() method is called on a null Log object in the Log.equals() method during a comparison between two items in the RecyclerView. The DiffUtil process, used to update the list asynchronously via AsyncListDiffer, attempts to compare the items, but one of the objects being compared is null. This leads to a NullPointerException, as the equals() method cannot be invoked on a null reference.

Stack Trace

Non-fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.Object.equals(java.lang.Object)' on a null object reference
       at com.eup.codeopsstudio.logging.Log.equals(Log.java:121)
       at com.eup.codeopsstudio.logging.LogAdapter$1.areItemsTheSame(LogAdapter.java:54)
       at com.eup.codeopsstudio.logging.LogAdapter$1.areItemsTheSame(LogAdapter.java:51)
       at androidx.recyclerview.widget.AsyncListDiffer$1$1.areItemsTheSame(AsyncListDiffer.java:308)
       at androidx.recyclerview.widget.DiffUtil.diffPartial(DiffUtil.java:268)
       at androidx.recyclerview.widget.DiffUtil.calculateDiff(DiffUtil.java:145)
       at androidx.recyclerview.widget.DiffUtil.calculateDiff(DiffUtil.java:105)
       at androidx.recyclerview.widget.AsyncListDiffer$1.run(AsyncListDiffer.java:292)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
       at java.lang.Thread.run(Thread.java:929)

System Information

  • Package Name: com.eup.codeopsstudio
  • App Version: 1.0.0 (1)

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions