Skip to content

Diagnose #5759: Add context to AcquisitionsDialog btnDepod NPE#8888

Merged
HammerGS merged 3 commits into
MegaMek:mainfrom
VicenteCartas:vc/5759
Apr 27, 2026
Merged

Diagnose #5759: Add context to AcquisitionsDialog btnDepod NPE#8888
HammerGS merged 3 commits into
MegaMek:mainfrom
VicenteCartas:vc/5759

Conversation

@VicenteCartas

Copy link
Copy Markdown
Collaborator

Related to #5759. Does not fix the bug

The btnDepod listener in AcquisitionsDialog calls part.getMissingPart().setOmniPodded(true) with no null check. The button's visibility guard runs only at panel build time, so a state change before click can produce the reported NPE. The Sentry trace alone doesn't tell us which part or state caused it.

This PR null-checks getMissingPart(), logs an error with part name/id, omniPodCount, missingCount, and isOmniPoddable (forwarded to Sentry via MMLogger), then rethrows so existing error handling is unchanged. Next occurrence will give us actionable context for a real fix.

Copilot AI review requested due to automatic review settings April 21, 2026 03:38
@VicenteCartas VicenteCartas requested a review from a team as a code owner April 21, 2026 03:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds diagnostic context around the btnDepod ActionListener in AcquisitionsDialog to help identify the root cause of issue #5759 (NPE from part.getMissingPart() becoming null between panel construction and button click).

Changes:

  • Adds a null-check for part.getMissingPart() inside the btnDepod click handler.
  • Logs detailed context (part name/id, omniPodCount, missingCount, isOmniPoddable) via MMLogger for Sentry visibility.
  • Rethrows a NullPointerException to preserve the existing global uncaught-exception handling behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov

codecov Bot commented Apr 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 13.82%. Comparing base (4f097d2) to head (42746e8).
⚠️ Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
MekHQ/src/mekhq/gui/dialog/AcquisitionsDialog.java 0.00% 12 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##               main    #8888   +/-   ##
=========================================
  Coverage     13.81%   13.82%           
- Complexity     8170     8176    +6     
=========================================
  Files          1282     1282           
  Lines        167371   167383   +12     
  Branches      25231    25232    +1     
=========================================
+ Hits          23119    23133   +14     
+ Misses       141925   141919    -6     
- Partials       2327     2331    +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@IllianiBird IllianiBird left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Good shout

@rjhancock

Copy link
Copy Markdown
Collaborator

Don't need to re-throw. The Uncaught Handler will also submit to Sentry (if enabled).

If it is something that can be dealt with and moved on, do so. As in if we can safely recover from it and move on, put up a dialog stating something changed and changes unsaved/try again, capture the error, report it, and move on. No need to log it twice.

@VicenteCartas

Copy link
Copy Markdown
Collaborator Author

Don't need to re-throw. The Uncaught Handler will also submit to Sentry (if enabled).

If it is something that can be dealt with and moved on, do so. As in if we can safely recover from it and move on, put up a dialog stating something changed and changes unsaved/try again, capture the error, report it, and move on. No need to log it twice.

Sounds good, I'll handle it instead of throwing.

@VicenteCartas

Copy link
Copy Markdown
Collaborator Author

Don't need to re-throw. The Uncaught Handler will also submit to Sentry (if enabled).

If it is something that can be dealt with and moved on, do so. As in if we can safely recover from it and move on, put up a dialog stating something changed and changes unsaved/try again, capture the error, report it, and move on. No need to log it twice.

Updated with your feedback.

@rjhancock rjhancock left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Sanity Check Complete.

@VicenteCartas

Copy link
Copy Markdown
Collaborator Author

@rjhancock Same, I can't merge :)

@rjhancock

Copy link
Copy Markdown
Collaborator

I only did a sanity check on the code. I'll let someone else test it and merge.

Comment on lines +575 to +582
logger.error(ise,
"btnDepod clicked but part.getMissingPart() returned null. " +
"part={} (id={}), omniPodCount={}, missingCount={}, isOmniPoddable={}",
part.getName(),
part.getId(),
partCountInfo.getOmniPodCount(),
partCountInfo.getMissingCount(),
part.isOmniPoddable());

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

You have this wrong, that's correct as there are 5 {}

@HammerGS HammerGS merged commit db50213 into MegaMek:main Apr 27, 2026
8 checks passed
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.

6 participants