-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
fix: use accountName only if User present #15775
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
1c73e87 to
154fbf0
Compare
|
|
||
| val user = optionalUser.get() | ||
| setupDrawer() | ||
| if (!optionalUser.isPresent || storageManager == null) return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey. Thank you for the PR.
if (optionalUser.isPresent && storageManager != null) {
if (!optionalUser.isPresent || storageManager == null) return
These two conditions are logically equivalent — they express the same control flow in opposite forms. Therefore, changing one to the other wouldn’t actually resolve the issue.
The real problem likely occurs when the app is suspended and then resumed, during which the state (such as optionalUser or storageManager) is lost or not properly restored.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two conditions are logically equivalent — they express the same control flow in opposite forms. Therefore, changing one to the other wouldn’t actually resolve the issue.
Switching the conditions permits the early return, which avoids running the later NPE code path though, right? (which in the existing code happens outside the conditional)
The real problem likely occurs when the app is suspended and then resumed, during which the state (such as optionalUser or storageManager) is lost or not properly restored.
I can't argue there. Admittedly did not go down that rabbit hole.
I guess the path forward comes down to two questions:
- Is the true underlying problem (suspend/resume state) readily fixable in the near future?
- What's the impact (cons specifically) of returning w/o at least crashing (as proposed in this PR)? I.e., Are we likely introducing new problems or just working around one until we can identify and fix the state matter?
I don't have the answers. Just posing to think about these a bit myself. :) To answer I'd have to take a deeper dive, which admittedly I haven't on this matter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR doesn’t seem likely to introduce any new issues, so we can go ahead and merge it. It might even help by returning early instead of failing within the condition.
As for the actual fix, it’s not an easy issue to reproduce or verify because of the tightly coupled, nested fragment hierarchy and the complexity of tracking their lifecycles. The NPE seems related to a specific execution flow — in theory, if the optional user is present, the user object should be accessible, but it appears there’s a lifecycle-related issue causing the null reference.
I’ll investigate this further, but thank you for the PR 🙏
Fixed #15771 Signed-off-by: Josh <[email protected]>
154fbf0 to
598e567
Compare
|
APK file: https://www.kaminsky.me/nc-dev/android-artifacts/15775.apk |

Should fix #15771
Despite appearances, basically a one like change. The rest is just indentation change because the early return eliminates the need to have the rest inside the replaced conditional.