Skip to content
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

Fix some potential NPEs when session is null #1784

Merged
merged 7 commits into from
Feb 15, 2022
Merged

Conversation

bilal-alsharifi
Copy link
Contributor

Fixes #1781

This PR is ready for review.

Risk

This PR makes no API changes.

Testing Plan

  • I have verified that I have not introduced new warnings in this PR (or explain why below)
  • I have run the unit tests with this PR
  • I have tested this PR against Core and verified behavior (if applicable, if not applicable, explain why below).
  • I have tested Android

Summary

This PR fixes some potential NPEs that could happen if functions from session are called when the object is null.

CLA

@codecov
Copy link

codecov bot commented Jan 7, 2022

Codecov Report

Merging #1784 (1c1930f) into develop (b51cda0) will decrease coverage by 0.06%.
The diff coverage is 9.85%.

❗ Current head 1c1930f differs from pull request most recent head 85e7f29. Consider uploading reports for the commit 85e7f29 to get more accurate results

Impacted file tree graph

@@              Coverage Diff              @@
##             develop    #1784      +/-   ##
=============================================
- Coverage      54.39%   54.32%   -0.07%     
- Complexity      5516     5521       +5     
=============================================
  Files            562      562              
  Lines          25543    25590      +47     
  Branches        3328     3338      +10     
=============================================
+ Hits           13893    13903      +10     
- Misses         10391    10424      +33     
- Partials        1259     1263       +4     
Impacted Files Coverage Δ
...elink/managers/lifecycle/BaseLifecycleManager.java 13.76% <9.85%> (-0.22%) ⬇️
...smartdevicelink/encoder/VirtualDisplayEncoder.java 44.91% <0.00%> (-0.36%) ⬇️
...ink/managers/screen/BaseTextAndGraphicManager.java 64.16% <0.00%> (+0.41%) ⬆️
...rtdevicelink/streaming/video/SdlRemoteDisplay.java 50.00% <0.00%> (+6.09%) ⬆️

Copy link
Contributor

@RHenigan RHenigan left a comment

Choose a reason for hiding this comment

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

These changes look good, I think the only thing we need to add is we should wrap the initialization of session in a synchronized block as well. Can you also add a new comment or update the existing comment to better capture what changes this PR makes?

@noah-livio
Copy link
Contributor

These changes look good, I think the only thing we need to add is we should wrap the initialization of session in a synchronized block as well. Can you also add a new comment or update the existing comment to better capture what changes this PR makes?

Sounds good, I'll make that change, and yeah I'll add a new comment to better reflect the current changes

@noah-livio
Copy link
Contributor

Fixes #1781

This PR is ready for review.

Risk

This PR makes no API changes.

Testing Plan

  • I have verified that I have not introduced new warnings in this PR (or explain why below)
  • I have run the unit tests with this PR
  • I have tested this PR against Core and verified behavior (if applicable, if not applicable, explain why below).
  • I have tested Android

Summary

This PR ensures all access to session in BaseLifecycleManager and LifecycleManager is synchronized and protected using null checks to prevent NPEs related to session from occurring.

CLA

@RHenigan RHenigan merged commit e740133 into develop Feb 15, 2022
@RHenigan RHenigan deleted the bugfix/issue_1781 branch February 15, 2022 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants