Skip to content

Conversation

@pm-dimagi
Copy link
Contributor

@pm-dimagi pm-dimagi commented May 9, 2025

Product Description

Fixed the crash when clicking on the message icon
https://dimagi.atlassian.net/browse/QA-7742
cross-request: dimagi/commcare-core#1475
QA-7745

New bug
firebase stacktrace

Technical Summary

Feature Flag

Safety Assurance

Safety story

Automated test coverage

QA Plan

Labels and Review

  • Do we need to enhance the manual QA test coverage ? If yes, the "QA Note" label is set correctly
  • Does the PR introduce any major changes worth communicating ? If yes, the "Release Note" label is set and a "Release Note" is specified in PR description.
  • Risk label is set correctly
  • The set of people pinged as reviewers is appropriate for the level of risk of the change

@pm-dimagi
Copy link
Contributor Author

@coderabbitai full review please

@coderabbitai
Copy link

coderabbitai bot commented May 9, 2025

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Get the PR description to understand its purpose
gh pr view 3095 --json title,body

# Get the list of files changed in the PR
gh pr view 3095 --json files

Length of output: 1943


🏁 Script executed:

#!/bin/bash
# Get the diff for the changed file to see the specific changes
gh pr view 3095 --json files -q '.files[].path' | xargs -I {} gh pr diff 3095 --name-only {} | grep -v "^@@" | grep -v "^diff" | grep -v "^index"

# Get the full content of the ConnectManager.java file to understand the context better
cat app/src/org/commcare/connect/ConnectManager.java

Length of output: 26762


🏁 Script executed:

#!/bin/bash
# Get the diff for the changed file without filtering
gh pr diff 3095

# Let's also try to understand the error that's being fixed by looking at the Firebase stacktrace
# First, check if there's any more information in the PR that might help us understand the issue better
gh pr view 3095 --json comments

Length of output: 1466


@pm-dimagi I've reviewed PR #3095 which fixes a crash when clicking on the message icon. Here's my assessment:

Issue Identified

The crash is occurring because goToMessaging() is a static method that was trying to access the non-static field manager.parentActivity. This would cause a NullPointerException if the manager instance wasn't properly initialized at the time of method call.

Fix Analysis

The changes made are:

  1. Changed parentActivity from instance to static variable
  2. Updated the goToMessaging() method to assign directly to the static variable

This is an appropriate fix because it aligns the variable scope with how it's being accessed in the static methods of the class.

Recommendations

The fix looks solid, but I'd suggest:

  • Consider adding a unit test to verify this behavior doesn't regress in the future
  • The class mixes static utility methods with singleton instance management, which might be worth revisiting in a future refactoring

Overall, this is a clean, minimal fix that directly addresses the crash issue.

}

private static ConnectManager getInstance() {
public static ConnectManager getInstance() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if we made this public we will need to also mange the singleton lifecycle better and make sure that concurrent calls to this only creates one instance. As such it's probably better to keep this private for now and in goToMessaging method call getInstance().parentActivity instead of just manager.parentActivity.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pm-dimagi pm-dimagi requested a review from shubham1g5 May 9, 2025 11:00
@pm-dimagi pm-dimagi merged commit 1051052 into pm_beta_relase_472005 May 9, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants